How can I sort the dataframe?
Please how can I sort this dataframe, such that for each year, the data is sorted in descending order. I tried using the .sort_values() I got this dataframe below and which is not what I want.
A simple Dataframe that can be used to represent the given dataframe in the picture.
myDic = {'Custmers':['A1','A1','A1','B4','A7','B4'],'Month':['May','June','June','June','July','August'],'Type':['Bag','Bag','Food','Drink', 'Cow','Cup'],'Year':[2004,2004,2005,2004, 2005, 2004]}
df = pd.DataFrame(myDic)
df.groupby(['Year','Month']).count()
How do I sort this given dataframe such that the june row in 2004 comes before august?
from Recent Questions - Stack Overflow https://ift.tt/2JiLLqo
https://ift.tt/3lfm0on
Comments
Post a Comment