如何增加 pandas 系列中截断显示的行数
How to increase number of truncated displayed rows in pandas series
在终端中,我将 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 行?
从the docs开始,您可以使用pd.options.display.min_rows
。
Once the display.max_rows is exceeded, the display.min_rows options determines how many rows are shown in the truncated 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]
在终端中,我将 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 行?
从the docs开始,您可以使用pd.options.display.min_rows
。
Once the display.max_rows is exceeded, the display.min_rows options determines how many rows are shown in the truncated 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]