I have a dataset that looks like this:
country date_added
0 United States 01/2013
1 United Kingdom 03/2014
2 Egypt 03/2014
3 United States 03/2014
4 United States 03/2014
5 United Kingdom 06/2015
6 United States 06/2015
And I would like a running cumulative total of each country by date, ie:
date_added country cumulative_count
0 01/2013 United States 1
1 03/2014 United Kingdom 1
2 03/2014 Egypt 1
3 03/2014 United States 2
4 06/2015 United Kingdom 2
5 06/2015 United States 4
I tried grouping by two levels but .count() doesn't work (the count doesn't show up at all) whereas .size() does:
cumulative_by_date = new_df.groupby(['date_added','country']).size()
I don't know how to apply this question's solution with .size() to get a cumulative sum.