Visualization Options for Jupyter Notebooks

Last updated:
Table of Contents

Reasonable default options for pandas dataframes

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

Show full text columns on dataframe

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 1000 looks like enough

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

Set max display columns for dataframe

use pandas.set_option('display.max_columns',1000)

Set max number of rows to display

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

Show full numpy arrays and pandas Series

threshold controls the number of elements that trigger truncation.

import numpy as np

# show 

Show more edge items

edgeitems controls the number of elements shown when truncation is triggered

import numpy as np

# show 10 elements on either side


Dialogue & Discussion