I trying to run my code but i had this msg ,what should I do ?'function' object has no attribute 'iloc'
top_10_cases=dataset.groupby(by='State/UnionTerritory').max()[['ActiveCases','Date']].sort_values(by=['ActiveCases'],ascending=False).reset_index
ax=sns.barplot(data=top_10.iloc[:10 ,x = 'State/UnionTerritory', y = 'ActiveCases',linewith=2 ,color = 'red')
top_10_activecases=dataset.groupby(by='State/UnionTerritory').max()['ActiveCases','Date'])
plt.xlabel("States")
plt.ylabel("total Active Cases")
plt.show()````
CodePudding user response:
You are missing the function call on the object. Try .reset_index()
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.reset_index.html