Expanding columns and rows in pandas results in Jupyter notebook

Expanding column widths

By default, when executed in a Jupyter notebook, pandas results have their columns truncated to about 200px.

This sometimes obscures interesting parts of the results

One way to expand the column widths is to increase the max-width:

from pandas import option_context
with option_context('display.max_colwidth', 400):
    display(df.head())

This example expands columns that have long values, up to 400px.

Expanding row counts

similarly, more rows can be displayed via this setting:

pd.set_option('display.max_rows', 500)


Comments