Pandas DataFrame Sort: want to sum and sort but keep the column names

Right now, I am running a sum and sorting by DataFrame object:

games_tags.groupby(['GameID', 'GameName', 'Tag']).sum().sort(['Count'], ascending=False)

The problem I am facing is that subsequently I want to be able to still capture every line of GameID, GameName and Tag via line ['GameID'], etc. However, I noticed that after using sum (), it creates a column called "Count", but I can no longer access any of the source columns.

I was wondering if anyone knows about the work or some complexity of the sum () method that I am missing. Any help is appreciated. Thank!

+3
source share
1 answer

reset groupby :

game_tags.reset_index(inplace=True)
+3

Source: https://habr.com/ru/post/1534373/


All Articles