Python Pandas Pivot Table Attribute Error


If anyone has any insight into why my code isn’t working, please help!

In my IDE, I am trying to make a pivot table with pandas with the following code:
category_pivot = category_counts.pivot(columns = ‘conservation_status’, index = ‘category’, values = ‘scientific_name’).reset_index()
Where category_counts = species.groupby([‘category’, ‘is_protected’]) and species is the original dataframe.

Instead of creating a new dataframe, I’m receiving the following error message:
AttributeError: Cannot access callable attribute ‘pivot’ of ‘DataFrameGroupBy’ objects, try using the ‘apply’ method

I’m using these versions:
Pandas Version: 23.3
Python Version: 3.7