Home > front end >  Python Dataframe Plotting by rows
Python Dataframe Plotting by rows

Time:09-17

I am using a dataframe that has the 1st, 2nd, and 3rd place scores as the rows and the years of those scores by column. I am trying to create a stacked bar chart in order to show the scores by year stacked by 1st, 2nd, and 3rd place. I don't know how to get it to stack properly without row names?

enter image description here

CodePudding user response:

Try:

>>> df.rename(index={0: "first", 1: "second", 2: "third"}).T.plot.bar(stacked=True)

Output:

enter image description here

  • Related