How do I expand the output display to see more columns of a pandas DataFrame?

后端 未结 19 1612
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 00:37

Is there a way to widen the display of output in either interactive or script-execution mode?

Specifically, I am using the describe() function on a pand

相关标签:
19条回答
  • 2020-11-22 01:18

    It seems like all above answers solve the problem. One more point: instead of pd.set_option('option_name'), you can use the (auto-complete-able)

    pd.options.display.width = None
    

    See Pandas doc: Options and Settings:

    Options have a full “dotted-style”, case-insensitive name (e.g. display.max_rows). You can get/set options directly as attributes of the top-level options attribute:

    In [1]: import pandas as pd
    
    In [2]: pd.options.display.max_rows
    Out[2]: 15
    
    In [3]: pd.options.display.max_rows = 999
    
    In [4]: pd.options.display.max_rows
    Out[4]: 999
    

    [...]

    for the max_... params:

    max_rows and max_columns are used in __repr__() methods to decide if to_string() or info() is used to render an object to a string. In case python/IPython is running in a terminal this can be set to 0 and pandas will correctly auto-detect the width the terminal and swap to a smaller format in case all columns would not fit vertically. The IPython notebook, IPython qtconsole, or IDLE do not run in a terminal and hence it is not possible to do correct auto-detection. None’ value means unlimited. [emphasis not in original]

    for the width param:

    Width of the display in characters. In case python/IPython is running in a terminal this can be set to None and pandas will correctly auto-detect the width. Note that the IPython notebook, IPython qtconsole, or IDLE do not run in a terminal and hence it is not possible to correctly detect the width.

    0 讨论(0)
提交回复
热议问题