0

Hey i have a data frame which contains many columns, when i try to sort them after i grouped them it says this Cannot access callable attribute 'sort_values' of 'DataFrameGroupBy' objects, try using the 'apply' method

the code is here df.groupby('year').sort_values(by = 'population')

niimet
  • 95
  • 1
  • 9
  • It is same like `df = df.sort_values(['year','population'])`, no `groupby` is necessary here – jezrael Feb 05 '20 at 12:51
  • 1
    no its is needed. – niimet Feb 05 '20 at 12:53
  • Ok, so please add [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) with expected output and explain, why `df = df.sort_values(['year','population'])` cannot be used here, then I can reopen question. Thanks – jezrael Feb 05 '20 at 12:54

0 Answers0