【问题标题】:How to increase number of truncated displayed rows in pandas series如何增加熊猫系列中截断的显示行数
【发布时间】:2019-12-11 16:56:20
【问题描述】:

在终端中,我将pd.options.display.max_rows 设置为 60。但对于超过 60 行的系列,显示将被截断为仅显示 10 行。如何增加显示的截断行数?

例如,以下(在 max_rows 设置内)显示 60 行数据:

s = pd.date_range('2019-01-01', '2019-06-01').to_series()
s[:60]

但如果我要求 61 行,它会被严重截断:

In [44]: s[:61]
Out[44]:
2019-01-01   2019-01-01
2019-01-02   2019-01-02
2019-01-03   2019-01-03
2019-01-04   2019-01-04
2019-01-05   2019-01-05
                ...
2019-02-26   2019-02-26
2019-02-27   2019-02-27
2019-02-28   2019-02-28
2019-03-01   2019-03-01
2019-03-02   2019-03-02
Freq: D, Length: 61, dtype: datetime64[ns]

如何设置它,例如,每次超过 max_rows 限制时我看到 20 行?

【问题讨论】:

    标签: python pandas printing console series


    【解决方案1】:

    来自the docs,您可以使用pd.options.display.min_rows

    一旦超过 display.max_rows,display.min_rows 选项将决定截断的 repr 中显示多少行。

    示例:

    >>> pd.set_option('max_rows', 59)
    >>> pd.set_option('min_rows', 20)
    >>> s = pd.date_range('2019-01-01', '2019-06-01').to_series()
    >>> s[:60]
    2019-01-01   2019-01-01
    2019-01-02   2019-01-02
    2019-01-03   2019-01-03
    2019-01-04   2019-01-04
    2019-01-05   2019-01-05
    2019-01-06   2019-01-06
    2019-01-07   2019-01-07
    2019-01-08   2019-01-08
    2019-01-09   2019-01-09
    2019-01-10   2019-01-10
                    ...
    2019-02-20   2019-02-20
    2019-02-21   2019-02-21
    2019-02-22   2019-02-22
    2019-02-23   2019-02-23
    2019-02-24   2019-02-24
    2019-02-25   2019-02-25
    2019-02-26   2019-02-26
    2019-02-27   2019-02-27
    2019-02-28   2019-02-28
    2019-03-01   2019-03-01
    Freq: D, Length: 60, dtype: datetime64[ns]
    

    【讨论】:

      猜你喜欢
      • 2017-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-25
      • 2014-08-29
      • 1970-01-01
      • 2018-02-16
      • 2014-11-30
      相关资源
      最近更新 更多