Reputation: 11
I have a simple issue that I would appreciate if someone can help me with
I'm grouping a dataframe by two columns to create a multiindex dataframe. Then, I want to create a bar plot for each each group:
df.groupby(['Teacher_name','Class_name'], sort = True).Student_ID.count()
Here is an image of the bar plots I'm looking for, i.e., a plot for each teacher with the number of students in each class.
Upvotes: 1
Views: 930
Reputation: 2108
You should install plotly and use the wonderful plotly express like this :
import plotly.express as px
fig = px.histogram(df, x="Class_name", facet_col="Teacher_name")
fig.update_layout(autosize=False, width=600, height=300) # resize figure
fig.show()
Upvotes: 2