简体   繁体   English

如何在熊猫图表中显示多值列?

[英]How Can I Display Multi-Value Columns in Pandas Chart?

I've got a 4 dataframes with different values: 我有一个具有不同值的4个数据框:

        CAND
YES        5
NO         0
        MARK
YES        4
NO         1
        TRBL
YES        0
NO         0
      STATUS
Inactive   3
Active     2

Ideally I'd like a bar chart where the X axis has 2 bars for each DF (since there's 2 possible values per DF) and the Y axis is the total count for each. 理想情况下,我想要一个条形图,其中X轴为每个DF有2条(因为每个DF有2个可能的值),Y轴为每个DF的总数。 I've scoured through the Pandas Visualization documentation but it's dealing primarily with numbers and displaying values for one specific column of a worksheet or dataframe whereas I'm trying to show multiple values from multiple dataframes in one bar chart. 我已经遍历了Pandas Visualization文档,但是它主要处理数字并显示工作表或数据框的一个特定列的值,而我试图在一个条形图中显示多个数据框的多个值。

This does need to be embedded into an HTML email as well. 确实也需要将其嵌入HTML电子邮件中。 Is this possible or am I dreaming up something? 这可能还是我在做梦?

If you have 4 dataFrames defines as df1, df2, df3, df4 Plot them in one chart this way: 如果您有4个dataFrames定义为df1, df2, df3, df4 ,请按照以下方式在一张图表中进行绘制:

import matplotlib.pyplot as plt

fig, axes = plt.subplots(nrows=2, ncols=2)

df1.plot(kind = bar, ax=axes[0,0])
df2.plot(kind = bar, ax=axes[0,1])
df3.plot(kind = bar, ax=axes[1,0])
df4.plot(kind = bar, ax=axes[1,1])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM