import pandas as pd
import numpy as np
Options and Settings β Controlling Pandas Display BehaviorΒΆ
Pandas provides a comprehensive options system for controlling how DataFrames are displayed in notebooks and terminals. Key settings include display.max_rows and display.max_columns (how many rows/columns to show before truncating), display.precision (decimal places for floats), and many more. You can access options via pd.options.display.*, pd.get_option(), pd.set_option(), pd.reset_option(), and pd.describe_option().
Why this matters: When working with large datasets (thousands of rows, dozens of columns), the default display settings often hide important data. Adjusting these options lets you see exactly the portion of data you need during exploration, and controlling float precision prevents visual clutter from excessive decimal places.
data = np.random.randint(1,100,[1000,50])
df = pd.DataFrame(data)
df.tail()
pd.options.display.max_rows
pd.options.display.max_rows = 2
df
pd.options.display.max_columns = 5
df
pd.get_option("max_columns")
pd.set_option("max_columns",20)
pd.reset_option
pd.describe_option("max_columns")
pd.DataFrame(np.random.randn(5,5))
pd.get_option("precision")
pd.set_option("precision",2)
df