I have a DataFrame with a time series like so:
timestamp v IceCreamOrder Location
2018-01-03 02:21:16 Chocolate South
2018-01-03 12:41:12 Vanilla North
2018-01-03 14:32:15 Strawberry North
2018-01-03 15:32:15 Strawberry North
2018-01-04 02:21:16 Strawberry North
2018-01-04 02:21:16 Rasberry North
2018-01-04 12:41:12 Vanilla North
2018-01-05 15:32:15 Chocolate North
And I want to get the counts like this:
timestamp strawberry chocolate
1/2/14 0 1
1/3/14 2 0
1/4/14 1 0
1/4/14 0 0
1/4/14 0 0
1/5/14 0 1
Since this is time series data, I've been storing the timestamp in pandas datetimeindex format.
I started by trying to get the counts for 'strawberry'. I ended up with this code that doesn't work.
mydf = (inputdf.set_index('timestamp').groupby(pd.Grouper(freq = 'D'))['IceCreamOrder'].count('Strawberry'))
Which results in an error:
TypeError: count() takes 1 positional argument but 2 were given
Any help would be greatly appreciated.