【问题标题】:Axis bug on Pandas groupby boxplotsPandas groupby 箱线图上的轴错误
【发布时间】:2014-08-11 12:42:28
【问题描述】:

我的 Pandas 数据框的头部 df 如下所示:

  count1  count2  totalcount  season
0       3      13          16       1
1       8      32          40       1
2       5      27          32       1
3       3      10          13       1
4       0       1           1       1

我想制作 count1count2totalcount 的箱线图,按 season 分组(有 4 个季节),并让每组箱线图显示在各自的子图中单人图。

当我只使用其中两列(例如 count1count2)时,一切看起来都很棒。

df.boxplot(['count1', 'count2'], by='season')

但是当我将totalcount 添加到组合中时,轴限制变得混乱。

df.boxplot(['count1', 'count2', 'totalcount'], by='season')

无论列的顺序如何,都会发生这种情况。我知道有几种方法可以解决这个问题,但如果能正常工作会更方便。

我错过了什么吗?这是 Pandas 中的一个已知错误吗?我在第一遍 Pandas 错误报告中找不到任何内容。

我正在使用 Pandas 0.14.0 和 matplotlib 1.3.1。

【问题讨论】:

    标签: python matplotlib pandas


    【解决方案1】:

    您是否尝试升级您的 pandas/matplotlib 包?

    我正在使用 Pandas 0.13.1 + Matplotlib 1.2.1,这是我得到的情节:

    In [31]: df
    Out[34]: 
        count1  count2  totalcount  season
    0        3      13          16       1
    1        8      32          40       1
    2        5      27          32       1
    3        3      10          13       1
    4        0       1           1       1
    5        3      13          16       2
    6        8      32          40       2
    7        5      27          32       3
    8        3      10          13       3
    9        0       1           1       4
    10       3      10          13       4
    11       3      13          16       4
    
    [12 rows x 4 columns]
    

    【讨论】:

    • 有趣 - 我实际上使用的是 Pandas 0.14.0 和 matplotlib 1.3.1。
    • @Greg,确实如此。我升级到你的版本,问题就在那里。
    猜你喜欢
    • 2013-10-27
    • 2015-07-04
    • 2017-11-24
    • 2018-04-28
    • 1970-01-01
    • 2020-01-25
    • 1970-01-01
    • 2021-06-26
    • 1970-01-01
    相关资源
    最近更新 更多