Home > Enterprise >  Changing the left order of dataframe in pandas
Changing the left order of dataframe in pandas

Time:09-30

so I have this code right here :

rev_table = playstore.groupby(['Category','App']).\
agg({'Reviews' : 'sum', 'Rating' : 'mean'}).reset_index().sort_values(by = 'Reviews', ascending =False).head(10)

and the result is like this image_result so I want to change the left number in the data frame for example the first one is '266192' and I want to change it to 1 and so on, so it can be in order.

CodePudding user response:

Do the reset_index after sorting;

rev_table = playstore.groupby(['Category','App']).\
agg({'Reviews' : 'sum', 'Rating' : 'mean'}).sort_values(by = 'Reviews', ascending =False).reset_index().head(10)
  • Related