patternpythonCriticalCanonical
Pretty-print an entire Pandas Series / DataFrame
Viewed 0 times
seriesentireprettydataframepandasprint
Problem
I work with Series and DataFrames on the terminal a lot. The default
Is there a builtin way to pretty-print the entire Series / DataFrame? Ideally, it would support proper alignment, perhaps borders between columns, and maybe even color-coding for the different columns.
__repr__ for a Series returns a reduced sample, with some head and tail values, but the rest missing.Is there a builtin way to pretty-print the entire Series / DataFrame? Ideally, it would support proper alignment, perhaps borders between columns, and maybe even color-coding for the different columns.
Solution
You can also use the
This will automatically return the options to their previous values.
If you are working on jupyter-notebook, using
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).Code Snippets
with pd.option_context('display.max_rows', None, 'display.max_columns', None): # more options can be specified also
print(df)Context
Stack Overflow Q#19124601, score: 1597
Revisions (0)
No revisions yet.