gpt4 book ai didi

python - 在 pandas 数据框中绘制条形图

转载 作者:行者123 更新时间:2023-12-01 02:00:30 24 4
gpt4 key购买 nike

我有一个 pandas 数据框,如下所示:

Date         Day_of_month                                                           
2017/1/16 16
2016/2/16 16
2018/1/16 16
2015/1/17 17
2013/1/18 18

如何在 x 轴上绘制该月中的某一天并在 y 轴上绘制该月中特定日期(例如 16)的条目数的条形图?

最佳答案

使用Series.value_counts , Series.sort_index最后Series.plot.bar :

df['Day_of_month'].value_counts().sort_index().plot.bar()

enter image description here

关于python - 在 pandas 数据框中绘制条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49710178/

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