如何基于分组和分类值计数创建堆积的条形图

时间:2018-10-27 16:34:34

标签: python-3.x dataframe matplotlib pandas-groupby

输入:

dfB=pd.qcut(dfA, 4, labels=quartiles)

输出:

Label      
G       5309       3rd quartile to max
        6016    1st quartile to median
        5587       min to 1st quartile
PG      6687       3rd quartile to max
        5943    median to 3rd quartile
        5987    median to 3rd quartile
PG-13   6380       3rd quartile to max
        5954       3rd quartile to max
        6624       3rd quartile to max
R       6616    median to 3rd quartile
        6184    median to 3rd quartile
        5569    1st quartile to median

我正在尝试创建一个条形图,以可视化每个Label组(G,PG,PG-13,R)的每个四分位数类别的value_count()。下面的代码生成一个条形图,该条形图仅显示每个四分位数类别的value_count()。我不确定如何创建将每个Label组都考虑在内的堆叠条形图?

dfB.value_counts().plot.bar()

0 个答案:

没有答案