【问题标题】:Boxplot time series monthly and weekly箱线图时间序列每月和每周
【发布时间】:2021-05-21 19:27:51
【问题描述】:

我有一个熊猫时间序列,其索引包含几年的日期:

                        Sales
Order Date  
2019-01-01 03:07:00     11.99
2019-01-01 03:40:00     11.95
2019-01-01 04:56:00     150.00
2019-01-01 05:53:00     2.99
2019-01-01 06:03:00     23.90
...                     ...
2020-01-01 04:13:00     2.99
2020-01-01 04:21:00     11.95
2020-01-01 04:54:00     99.99
2020-01-01 05:13:00     99.99
2020-01-01 05:13:00     14.95

我正在尝试制作一个箱线图,其中包含特定年份每月和每周的总销售额。到目前为止,我已经尝试使用

对数据进行分组
weeks = [g.reset_index()
         for n, g in sales_dataframe.groupby(Grouper(freq='W'))]
months = [g.reset_index()
          for n, g in sales_dataframe.groupby(Grouper(freq='M'))]

我如何获得箱线图,例如 2019 年的月平均销售额和周平均销售额?

【问题讨论】:

  • 具有总销售额的箱线图?您是指平均销售额的箱线图吗?还是您的意思是总销售额的条形图?
  • @QuangHoang 平均

标签: pandas time-series boxplot


【解决方案1】:

我使用 Seaborn 找到了答案

sns.boxplot(x=sales_dataframe.index.month, y=sales_dataframe.Sales)

【讨论】:

    猜你喜欢
    • 2014-08-17
    • 1970-01-01
    • 2020-09-20
    • 1970-01-01
    • 2019-11-15
    • 2022-12-11
    • 2019-11-17
    • 2021-09-08
    • 1970-01-01
    相关资源
    最近更新 更多