I have a Pandas DataFrame that consists of a date column and a category column of interest. I would like to see the Frequency count for each month. When I did this with matplotlib, I get something that looks quite bad.
Here is what the frame looks like when grouped by the months:
df.resample("M")["category_col"].value_counts(normalize=True).mul(100)
Output
date category_col
2019-12-31 A 41.929004
B 25.758765
C 17.752111
D 9.189919
E 3.625122
F 1.745080
2020-01-31 A 54.052744
C 16.347271
B 14.414431
D 11.677537
E 2.675607
F 0.832411
2020-02-29 A 48.928468
D 22.011116
C 14.084507
C 11.729162
E 2.193272
F 1.053475
2020-03-31 A 54.435410
D 15.718065
C 14.577060
B 11.335682
E 2.884205
F 1.049578
Name: category_col, dtype: float64
Here what my attempt
df.date = pd.to_datetime(df.date)
df.set_index("date", inplace=True)
df.resample("M")["category_col"].value_counts(normalize=True).mul(100).plot(kind="bar")
See the output below:
Here is what I want:

