Hi, I am stuck on a review portion of the Learn Pandas: Aggregates section of the Data Analysis course. No matter what I have tried, I am not getting past syntax errors or other errors.
- Using the column is_click that we defined earlier, check to see if a greater percentage of users clicked on Ad A or Ad B.
The hint for the problem is “Group by both experimental_group and is_click and count the number of user_id’s. You might want to use a pivot table like we did for the utm_source exercises.”
I tried creating a pivot table but I have not been able to get it to work. This is the latest piece of code I tried:
clicks_pivot.groupby([‘expiremental_group’, ‘is_click’])[‘user_id’].count().reset_index()
But it is producing this (which is similar to other errors I received):
Traceback (most recent call last):
File “script.py”, line 20, in
clicks_pivot.groupby([‘expiremental_group’, ‘is_click’])[‘user_id’].count().reset_index()
File “/usr/local/lib/python2.7/dist-packages/pandas/core/generic.py”, line 4416, in groupby
**kwargs)
File “/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.py”, line 1699, in groupby
return klass(obj, by, **kwds)
File “/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.py”, line 392, in init
mutated=self.mutated)
File “/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.py”, line 2690, in _get_grouper
raise KeyError(gpr)
KeyError: ‘expiremental_group’
Any assistance would be appreciated.
Thanks,
Drew