I have a dataframe:
d={'year':['2011','2011','2011','2012','2012','2013','2013'],'sex':['M','F','M','M','F','F','M']}
df=pd.DataFrame(d)
I want to create new column for performing time series analysis, count of male and female each year. Output should be a dataframe like below:
I tried d1.groupby(['sex','year']).count(), but it did not do what i expected in output