-1

I have a trouble with pandas, Below is code:

print(right_df)

enter image description here

print(right_top)

enter image description here

g = right_df.groupby('exam_id').apply(right_top)
print(g)

The error is "TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed" how can i solve it??

boure Li
  • 29
  • 1
  • 5
  • 1
    Welcome to StackOverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Mar 27 '18 at 07:27

1 Answers1

1

You should pass a function to the apply(...). In your code, you pass a DataFrame, hence, pandas try to call the dataframe (__call__ method of the object pandas.DataFrame) and hence the error.

See explanation on apply here.

In order to help you with the specific problem, please provide more information on your intent.

mr_mo
  • 1,401
  • 6
  • 10