0

I noticed after I do a groupby in a dataframe and try to read the entire dataframe after that, the variable used for groupby doesnt show.

abc_df= merged_df.groupby[['Name', 'Gender']).first

When I try to call the variable abc_df['Name'], it doesn't show.

Is there a way to solve this?

Thanks

Celius Stingher
  • 17,835
  • 6
  • 23
  • 53
pot
  • 37
  • 3
  • `merged_df.groupby[['Name', 'Gender'], as_index=False).first()`. You didn't call the function and grouping columns will be converted to an index by default. – Michael Szczesny Dec 22 '21 at 13:27
  • Does this answer your question? [pandas groupby without turning grouped by column into index](https://stackoverflow.com/questions/32059397/pandas-groupby-without-turning-grouped-by-column-into-index) – Michael Szczesny Dec 22 '21 at 13:27
  • yes it does!! Thanks! – pot Dec 22 '21 at 13:45

0 Answers0