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.
Sure, if this comes up a lot, make a function like this one. You can even configure it to load every time you start IPython: https://ipython.org/ipython-doc/1/config/overview.html
As for coloring, getting too elaborate with colors sounds counterproductive to me, but I agree something like bootstrap's
.table-striped
would be nice. You could always create an issue to suggest this feature.If you are using Ipython Notebook (Jupyter). You can use HTML
Use the tabulate package:
And consider the following example usage:
No need to hack settings. There is a simple way:
After importing pandas, as an alternative to using the context manager, set such options for displaying entire dataframes:
For full list of useful options, see:
You can achieve this using below method. just pass the total no. of columns present in the DataFrame as arg to
For eg :