gpt4 book ai didi

python - 在Python的同一列中绘制数据

转载 作者:太空宇宙 更新时间:2023-11-03 21:24:35 24 4
gpt4 key购买 nike

我有一个具有两个特征的数据集:Identification_person 和 Day。为了计算出现了多少个不同的 id,我执行了以下操作:

 dfc= df.groupby(['Identification_person']).Day.nunique()

并获得:

  Identification_person
1003412255 1
1005776162 1
10240210418296 1
10240210425300 2
10240210425301 2
10240210425305 1
10240210425306 1

问题是我无法将“计数”列为一列,所以我不知道如何绘制它。我想在 x 轴上绘制人物,在 y 轴上绘制人物出现的不同天数。

有人知道如何绘制这个吗?

最佳答案

使用reset_index()

dfc= df.groupby(['Identification_person']).Day.nunique().reset_index()

现在你有了一个可以使用 Pandas 绘图函数/matplotlib 等的数据框。

关于python - 在Python的同一列中绘制数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53944906/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com