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 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.
You can also use the
option_context
, with one or more options:This will automatically return the options to their default values.
If you are working on jupyter-notebook, using
display
instead ofprint
will use jupyter rich display logic.Try this
This answer is a variation of the prior answer by lucidyan. It makes the code more readable by avoiding the use of
set_option
.After importing pandas, as an alternative to using the context manager, set such options for displaying large dataframes:
After this, you can use
display(df)
or justdf
if using a notebook, otherwiseprint(df)
.