Home > Software design >  python-pandas-changing the default x as index to columns instead
python-pandas-changing the default x as index to columns instead

Time:01-02

I have the following as my code with the following graph displaying enter image description here

enter image description here

Problem is, I wanted to compare each attribute(mean age, age amount etc) next to each other. By default, pandas takes x as the index. How do I change it to take column names instead(Then there will be 3 comparisons, one for each attribute)

CodePudding user response:

IIUC use transpose with DataFrame.plot.bar:

df.T.plot.bar()
  • Related