Pretty-print an entire Pandas Series / DataFrame

后端 未结 12 2495
再見小時候
再見小時候 2020-11-22 03:26

I work with Series and DataFrames on the terminal a lot. The default __repr__ for a Series returns a reduced sample, with some head and tail values, but the res

12条回答
  •  猫巷女王i
    2020-11-22 04:16

    You can also use the option_context, with one or more options:

    with pd.option_context('display.max_rows', None, 'display.max_columns', None):  # more options can be specified also
        print(df)
    

    This will automatically return the options to their previous values.

    If you are working on jupyter-notebook, using display(df) instead of print(df) will use jupyter rich display logic (like so).

提交回复
热议问题