gpt4 book ai didi

python - 如何在 python 中按分类顺序排序月份,即一月、二月、三月等......?

转载 作者:行者123 更新时间:2023-12-02 17:57:52 26 4
gpt4 key购买 nike

我正在创建一个在 x 轴上有“月份”的条形图,但是它们以随机顺序显示,我如何对月份进行逻辑排序,即一月、二月、三月...

这是我的代码...

    plt.figure(figsize=(15,10))
sns.countplot(x=boeing_df.order_month);
plt.title('Most Popular Order Month');ype here

TIA

最佳答案

您可以使用countplotorder参数并给出你的月份 list 。一个方便的方法可能是使用 calendar.month_abbr :

import calendar
sns.countplot(x=boeing_df.order_month, order=calendar.month_abbr[1:])

关于python - 如何在 python 中按分类顺序排序月份,即一月、二月、三月等......?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75215646/

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