1
votes

Hi I am having some trouble plotting sub-bar charts after a dataframe groupby

Post groupby, the data is as per the below :

enter image description here

I tried the below to create a bar chart.

df_temp[df_temp.index =='ABC'].unstack().plot.bar(figsize=(10,2))

enter image description here

How can I plot a bar charts where the x-axis is the date and y-axis is the count and each row (ABC and EFG) is its own subplot (vertically stacked)

Example below

enter image description here

thanks for your help !

1
df.T.plot(subplots=True, layout=(2,1), kind='bar')Try this.r-beginners
that works, for the x-axis. It is currently (Count, 2021-01-25) how can I change it to just date ?Lko
df.reset_index(inplace=True) Try this.r-beginners
Remove the multilevel column df.columns = df.columns.droplevel()Lko
It would be nice if the multi-indexing could be resolved. I think the way to do it is still good.r-beginners

1 Answers

2
votes

thanks to @r-beginnners

#remove the multi-level column    
df.columns = df.columns.droplevel()  

#plot the sub-plots
# if y-axis scale to be the same, use sharey=True 
df.T.plot(subplots=True, layout=(2,1), kind='bar', sharey=True)