1

I'm trying to get the top 10 longest songs in my data frame by calling two columns using the code df.loc[['duration_min','name']].head(). I have already sorted the relevant columns by descending order but when I run the code, I keep getting this error:

KeyError: "None of [Index(['duration_min', 'name'], dtype='object')] are in the [index]"

I was expecting the code to run without any problems

Koedlt
  • 4,286
  • 8
  • 15
  • 33

1 Answers1

0

Error shows that there are no indices called 'duration_min' and 'name'. You should use:

df[['duration_min', 'name']].head(x) 

with x, an integer.

VegTo91
  • 3
  • 3