0

how can I sort this code by fraudulent:enter image description here

df.pivot_table('fraudulent', index=['industry'], aggfunc=['count', 'mean']).sort_values(by='fraudulent', ascending=False)

and I got this error KeyError: 'fraudulent'

  • It looks like you want to sort by one column, so use `sort_values` by one of the new columns, you cannot sort directly by "fraudulent" as the column does not exist anymore, check the intermediate before sorting and provide a clear example – mozway Apr 19 '22 at 07:34

0 Answers0