【问题标题】:python-pandas-changing the default x as index to columns insteadpython-pandas-将默认 x 更改为列的索引
【发布时间】:2022-01-27 01:01:13
【问题描述】:

我将以下代码作为我的代码,并显示以下图表

问题是,我想比较旁边的每个属性(平均年龄、年龄等) 彼此。默认情况下,pandas 以 x 作为索引。如何将其更改为采用列名(然后将进行 3 个比较,每个属性一个)

【问题讨论】:

    标签: python pandas matplotlib


    【解决方案1】:

    IIUC 使用转置与DataFrame.plot.bar:

    df.T.plot.bar()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-29
      • 2016-06-15
      相关资源
      最近更新 更多