Reputation: 71
I've got the following pands dataframe:
date allocated_reason allocated bk_task
2019-10-27 AI Allocated 1051
2019-11-03 AI Allocated 1471
2019-10-27 Self Allocation Allocated 291
2019-11-03 Self Allocation Allocated 274
2019-11-10 Self Allocation Allocated 40
2019-10-27 AI Not Allocated 3570
2019-11-03 AI Not Allocated 3267
2019-11-10 AI Not Allocated 598
The date is the index and bk_tasks is the number of tasks for each combination: E.g. 1051 tasks in the week of 27/10 who are AI + Allocated.
I want to make a bar-plot witch has 2 bars for each week: 1 bar contains the number of not allocated tasks, the other the allocated task, and I want each bar to be grouped by AI or Self Allocation.
Upvotes: 2
Views: 102
Reputation: 416
You can easily render this with the help of following code:
import plotly.express as px
fig = px.bar(df, x="date", y="bk_task", color="allocated", barmode="group",
facet_col="allocated_reason",color_discrete_sequence=px.colors.diverging.Tealrose[-2::-1])
fig.show()
With the help of faceting, you can easily group the allocated_reasoning column.
Hope this helps!!!
Upvotes: 1