Home > database >  Plotly barchart using groupby
Plotly barchart using groupby

Time:03-14

I have a two column dataframe. There are 3 different codes possible

index----| Year-----| Code-----|
0        | 2020     | a        |
1        | 2020     | b        |
2        | 2020     | c        |
3        | 2021     | b        |
4        | 2021     | b        |

I want to plot a barchart so the x-axis shows the years , and above each year there should be 3 bars giving the amount of time the code occurs

CodePudding user response:

You can use a stack bars

Or, with stacked=False:

enter image description here

  • Related