A/B Testing for ShoeFly.com - question 10

I keep getting an error message (below) for my final calculation of percentages - can anyone tell me where I’ve gone wrong?

Traceback (most recent call last):
File “script.py”, line 68, in
a_clicks_pivot[‘percent_clicked’] = a_clicks_pivot[True] / (a_clicks_pivot[True] + a_clicks_pivot[False])
TypeError: ‘instancemethod’ object has no attribute ‘getitem

Hello @sgjbett2, welcome to the forums! By what your error is saying, I would assume that the cause is you are trying to call getitem on an object that has no getitem method. You might want to review the steps you’ve taken, and see where you have used getitem on the object instancemethod, and then see if there are steps you can take to either remove that, or add a getitem method to instancemethod.
I hope this helps!

__getitem__ is the method corresponding to the [] operator

class stuff:
    def __getitem__(self, key):
        return f'you asked for stuff()[{key}]'

print(stuff()[3])
1 Like

Was this question every answered? I’m getting the same problem for question SIX. I’m using the EXACT answer given in the video.

The fix is making sure to “reset_index()” the data before calling this function.