Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫条形图:使用聚合输出作为每个组的x轴和颜色_Python_Python 2.7_Matplotlib_Bar Chart_Aggregate Functions - Fatal编程技术网

Python 熊猫条形图:使用聚合输出作为每个组的x轴和颜色

Python 熊猫条形图:使用聚合输出作为每个组的x轴和颜色,python,python-2.7,matplotlib,bar-chart,aggregate-functions,Python,Python 2.7,Matplotlib,Bar Chart,Aggregate Functions,我有以下代码,结果列有值赢得或丢失: df.groupby('result')['col_A'].agg(['mean','median']).plot(kind='bar') 如何使x轴成为平均值和中值,并使用赢/输组的颜色?谢谢 您可以在打印之前转置数据帧: df.groupby('result')['col_A'].agg(['mean','median']).transpose().plot(kind='bar') 这将产生如下结果:

我有以下代码,
结果
列有值
赢得
丢失

 df.groupby('result')['col_A'].agg(['mean','median']).plot(kind='bar')


如何使x轴成为平均值和中值,并使用赢/输组的颜色?谢谢

您可以在打印之前转置数据帧:

df.groupby('result')['col_A'].agg(['mean','median']).transpose().plot(kind='bar')
这将产生如下结果: