Suppose I have following Data-Series:
Date Category
2014-8 Facebook
2014-8 Vimeo
2014-8 Facebook
2014-8 Facebook
2014-9 Facebook
2014-9 Orkut
2014-9 Facebook
2014-9 Facebook
2014-9 Facebook
...
2014-10 Youtube
2014-10 DailyMotion
2014-10 Facebook
2014-10 Vimeo
2014-10 Facebook
2014-10 Facebook
I would like to make a count of each category (Unique Value/Factor in the Time Series) per month and year.
Category Date Count
Facebook 2014-01 5
2014-02 6
2014-03 8
Vimeo 2014-01 3
2014-02 10
2014-03 9
youtube 2014-01 13
2014-02 61
2014-03 8
So, when I call Facebook, I can see how many times facebook occured on each month.
What I tried is:
df['Date'] = df['Date'].map(lambda x: '{year}-{month}'.format(year=x.year,
month=x.month,
day=x.day))
a = df.groupby(['Category','year-month']).size()