Pandas Display Options: Examples and Reference

Last updated:
Table of Contents

Version used: Pandas 1.0.1

Reasonable defaults

You can add this to the beginning of every notebook you write automatically: Add commands to the beginning of every notebook

import pandas as pd

# general options

# for text columns

Maximum text length

use pandas.set_option('display.max_colwidth',1000):

Say you have a column named 'synopsis' with text data:

before-set-option the default value for this setting is 50
after-set-option After setting max_max_colwidth
to 1000

Disable scientific notation

Use pandas.set_option('display.float_format', lambda x: '<fmtstring>' % x)

Example: use '%8.2f' as formatting:

import pandas as pd
pd.set_option('display.float_format', lambda x: '%8.2f' % x)

    "num":[0.0001, 10000000,100,0.5],

before-with-default-options BEFORE: default options
after-with-custom-options AFTER setting display.float_format

Max dataframe columns

Use pandas.set_option('display.max_columns', num)

Example: show up to 100 columns: pandas.set_option('display.max_columns',100)

Max dataframe rows

Use pandas.set_option('display.max_rows', num)

Example: show up to 100 rows: pandas.set_option('display.max_rows',100)

Disable math symbols

Use pandas.set_option('display.html.use_mathjax',False) to disable MathJax rendering on dataframe cells

Reset display options

Use pandas.reset_option("all") to reset all display options.

Reset single display option

Use pandas.reset_option("<option name>").

Example: pandas.reset_option('display.max_colwidth') to reset 'display.max_colwidth' to its default value

Dialogue & Discussion