完整打印熊猫索引

max*_*max 4 python pandas

为了打印熊猫DataFrameSeries完整版,我们可以使用pd.set_option('display.max_rows', None). 但这似乎不适用于Index数据类型:

import pandas as pd
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None) # just in case
d = {i: ['a'] for i in range(1000)}
df = pd.DataFrame(d)
print(df.columns)
Run Code Online (Sandbox Code Playgroud)

将打印

Int64Index([  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
        ...
        990, 991, 992, 993, 994, 995, 996, 997, 998, 999],
       dtype='int64', length=1000)
Run Code Online (Sandbox Code Playgroud)

有没有办法完整打印索引?

一般来说,有没有办法告诉熊猫永远不要缩写任何输出?

(python 3.5,pandas 0.17.1,但没关系。)

jor*_*ris 6

max_seq_items是用于此的选项:

In [21]: pd.options.display.max_seq_items
Out[21]: 100

In [22]: pd.options.display.max_seq_items = 4

In [23]: pd.Index(range(1000))
Out[23]:
Int64Index([  0,   1,
            ...
            998, 999], dtype='int64', length=1000)
Run Code Online (Sandbox Code Playgroud)

并将其设置为None将显示完整索引。

  • 与“pd.set_option('display.max_seq_items', None)”相同? (2认同)