I'm trying to use the pivot_table method of a pandas DataFrame;
mean_ratings = data.pivot_table('rating', rows='title', cols='gender', aggfunc='mean')
However, I receive the following error:
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-55-cb4d494f2f39> in <module>() ----> 1 mean_ratings = data.pivot_table('rating', rows='title', cols='gender', aggfunc='mean') TypeError: pivot_table() got an unexpected keyword argument 'rows'
The above command was taken from the book 'Python for Data Analysis' by Wes McKinney (the creator of pandas)
The solution for me was to change 'rows=>index' and 'cols=>columns'):
From:
mean_ratings = data.pivot_table('rating', rows='title', cols='gender', aggfunc='mean')
to:
mean_ratings = data.pivot_table('rating', index='title', columns='gender', aggfunc='mean')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With