I'm using Pandas and Matplotlib to plot some data from an SQL database.
Here are my steps:
- fetch the data from the DB into a pd.DataFrame
- group them using a Grouper('MS')
- aggregate to count how many items are there in each group
- draw the chart
df = df.groupby(Grouper(key='published_at', freq='MS'))['id'].count()
ax = df.plot.bar(position=0.5, width=0.4, label="Items")
This is what my plot looks like :
I'd like to show the months as "2019-04", so "Y-M", but I can't figure out how to do it.
As I'm totally new to Python, any help would be greatly appreciated. Thank you !