The source data is as follows:
Date E
0 2017-09-01 -
1 2017-09-01 +
2 2017-09-01 +
3 2017-09-01 +
...
...
After applying groupby:
df.groupby(['Date', 'E'])['Date'].count().to_frame(name = 'Count').reset_index()
I get a DataFrame that looks like this:
Date E Count
0 2017-09-01 + 11
1 2017-09-01 - 1
2 2017-09-04 + 1
3 2017-09-04 - 7
4 2017-09-05 + 1
5 2017-09-05 - 23
How can I convert this to a dataframe that looks like this:
Date + -
0 2017-09-01 11 1
2 2017-09-04 1 7
4 2017-09-05 1 23
source
share