【发布时间】:2021-11-12 03:30:47
【问题描述】:
我在 Pandas 中使用过 groupby,
df_0 = df_find_quality_und.groupby("user score").size()
df_0
并得到这个输出;
Output:
user score
3.0 14
7.0 2
7.1 1
7.2 2
7.3 1
7.5 1
7.7 1
7.8 2
7.9 1
8.0 1
8.1 2
8.3 1
8.7 1
dtype: int64
右边是数据的频率。
然后,我想将这些数据绘制成饼图。但我不知道如何把剩下的数据变成我饼图的标签。因此,我是这样手动编写的;
user_sc_und = [3.0,7.0,7.1,7.2,7.3,7.5,7.7,7.8,7.9,8.0,8.1,8.3,8.7]
user_sc_und_1 = df_find_quality_und.groupby("user score")
plot = plt.pie(df_0, labels=user_sc_und)
饼图很好地显示在带有标签的输出中。但是,我不想每次都手动编写标签。任何人都可以帮助我通过在左侧获取 groupby 数据来标记饼图吗?
谢谢。
【问题讨论】:
标签: python pandas database pandas-groupby data-analysis