Options & Settings
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
This page targets pandas 3.1 (released on 2026-10-22) on Python 3.13 or 3.14 with NumPy 2.5, and was checked in October 2026. Every example was run on pandas 3.1.0. The options system is the one place where pandas keeps global state: a setting changes how every object in the process behaves, so this page also explains how to scope a change instead of leaving it on forever.
The functions and option names come from the official Options and settings guide and from pd.describe_option() in the installed version, which is the authoritative list for the version you actually run. The next pages cover the options that matter for speed (Enhancing Performance) and for reading big files (Scaling to Large Datasets). For the printed form of a frame, see DataFrame, and for the HTML and LaTeX output of tables see Table Styling.
The five functions
pandas exposes the whole options API at the top level, with five functions. All of them take a dotted option name such as display.max_rows.
| Function | What it does |
|---|---|
|
Returns the current value. |
|
Changes a value. Accepts several name and value pairs in one call. The value is validated against the option’s type. |
|
Restores the default. |
|
Prints the description, valid values, default and current value. With no argument it prints every option. |
|
A context manager that sets one or more options and restores the previous values when the block ends, even if it raises. |
The same options are reachable as attributes of pd.options, so pd.options.display.max_rows reads the option and assigning to it sets it.
import pandas as pd
pd.set_option("display.max_rows", 5)
print(pd.get_option("display.max_rows"))
print(pd.options.display.max_rows) # attribute access reads the same option
pd.options.display.max_colwidth = 30 # attribute access also assigns
pd.reset_option("display.max_rows") # one option back to its default
pd.reset_option("display") # every option in the display group
print(pd.options.display.max_colwidth)
try:
pd.get_option("display.max_col") # matches max_columns and max_colwidth
except pd.errors.OptionError as exc:
print("OptionError:", exc)
try:
pd.set_option("display.max_rowz", 3)
except pd.errors.OptionError as exc:
print("OptionError:", exc)
try:
pd.set_option("display.precision", "x")
except ValueError as exc:
print("ValueError:", exc)
pd.describe_option("display.precision")
Output:
5
5
50
OptionError: Pattern matched multiple keys
OptionError: No such keys(s): 'display.max_rowz'
ValueError: Value must be a nonnegative integer or None
display.precision : int
Floating point output precision in terms of number of places after the
decimal, for regular formatting as well as scientific notation. Similar
to ``precision`` in :meth:`numpy.set_printoptions`.
[default: 6] [currently: 6]
Source: Options and settings.
Three details from that run are worth remembering:
-
The option name is matched as a regular expression with
re.search, and it must match exactly one option.display.max_colfails because two options start with it. The official guide warns that shorthand names may break when a later release adds a similar option, so write full names in code that has to keep working. -
A misspelt name raises
pd.errors.OptionErrorinstead of silently creating a setting, and a value of the wrong type raisesValueError. -
pd.reset_option("display")resets the entiredisplaygroup, including options you set elsewhere in the program. Prefer resetting one named option, or useoption_contextso nothing needs resetting.
Scoping a change with option_context
Calling set_option at the top of a script is fine for a personal analysis. In library code, in a function that prints, or in a notebook cell that should not leak into the next one, use option_context. It restores the values when the block exits.
import numpy as np
import pandas as pd
rng = np.random.default_rng(0)
df = pd.DataFrame(
rng.normal(size=(3, 12)),
columns=[f"column_{i}" for i in range(12)],
)
print(df) # defaults: columns are elided with "..."
with pd.option_context("display.max_columns", None, "display.width", 200, "display.precision", 2):
print(df) # every column, two decimals
print(pd.get_option("display.max_columns")) # the context manager restored the old value
Output (the second table is one wide line in a terminal):
column_0 column_1 column_2 ... column_9 column_10 column_11 0 0.125730 -0.132105 0.640423 ... -1.265421 -0.623274 0.041326 1 -2.325031 -0.218792 -1.245911 ... 1.366463 -0.665195 0.351510 2 0.903470 0.094012 -0.743499 ... 0.540846 0.214659 0.355373 [3 rows x 12 columns] column_0 column_1 column_2 column_3 column_4 column_5 column_6 column_7 column_8 column_9 column_10 column_11 0 0.13 -0.13 0.64 0.10 -0.54 0.36 1.30 0.95 -0.70 -1.27 -0.62 0.04 1 -2.33 -0.22 -1.25 -0.73 -0.54 -0.32 0.41 1.04 -0.13 1.37 -0.67 0.35 2 0.90 0.09 -0.74 -0.92 -0.46 0.22 -1.01 -0.21 -0.16 0.54 0.21 0.36 0
Source: Frequently used options.
The value 0 for display.max_columns is the default and means "detect the terminal width". Outside a real terminal (a script writing to a pipe, a test runner) there is nothing to detect, so the frame is elided as shown. Options are process-wide, not thread-local: two threads that enter option_context at the same time can see each other’s values, so do not rely on a context manager to isolate concurrent printing.
Display options
Display options change only how objects are rendered. They never change the data. These are the ones you will actually use.
| Option | Default | Effect |
|---|---|---|
|
|
Above this many rows a frame is truncated in the repr. |
|
|
How many rows the truncated view shows. Only used when the frame exceeds |
|
|
Above this many columns the repr elides the middle ones. |
|
|
Width in characters used when wrapping a wide frame. |
|
|
Wrap a wide frame over several blocks instead of eliding columns. |
|
|
Longest cell text shown before a trailing ellipsis. |
|
|
For a frame beyond the row or column limit, show a truncated table, or |
|
|
Digits after the decimal point for floats. |
|
|
A callable that turns a float into a string. |
|
|
Floats whose absolute value is below it print as |
|
|
|
|
|
Limits above which |
|
|
Longest list or index shown before |
|
|
Print the |
|
|
Whether |
|
|
Categories shown when printing a categorical. |
|
|
Measure double-width characters (CJK and most emoji) correctly when aligning columns. It has a performance cost. |
|
|
Publish a Table Schema representation for front ends that can render it. |
Source: Frequently used options.
The first two are the ones people reach for. A frame with more than max_rows rows prints min_rows of them, so raising max_rows alone to see a 100-row frame works, but raising min_rows without max_rows does nothing. Printing a million-row frame with max_rows set to None can freeze a notebook, which the option’s own description warns about.
For a quick look at a slice, df.head(n).to_string() or df.to_string(max_rows=...) is usually safer than changing a global.
Number formatting
Three options control how floats look. They change the display only: the stored values keep full precision, which is the same distinction as between print(df) and df.round(2).
import pandas as pd
s = pd.Series([1.23456789, 2.5, 1000.123456, 0.00001234])
print(s)
with pd.option_context("display.precision", 2):
print(s)
with pd.option_context("display.float_format", "{:,.2f}".format):
print(s)
with pd.option_context("display.float_format", lambda x: f"{x:.1e}"):
print(s)
with pd.option_context("display.chop_threshold", 0.001):
print(s)
print(s.round(2)) # changes the values, not only the display
df = pd.DataFrame({"text": ["x" * 80]})
print(df)
with pd.option_context("display.max_colwidth", None):
print(df)
Output:
0 1.234568
1 2.500000
2 1000.123456
3 0.000012
dtype: float64
0 1.23e+00
1 2.50e+00
2 1.00e+03
3 1.23e-05
dtype: float64
0 1.23
1 2.50
2 1,000.12
3 0.00
dtype: float64
0 1.2e+00
1 2.5e+00
2 1.0e+03
3 1.2e-05
dtype: float64
0 1.234568
1 2.500000
2 1000.123456
3 0.000000
dtype: float64
0 1.23
1 2.50
2 1000.12
3 0.00
dtype: float64
text
0 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
text
0 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Source: Number formatting.
Things to notice:
-
display.precisionof 2 switched the whole column to scientific notation, because the smallest value would otherwise print as0.00. pandas picks one format for the whole column. Afloat_formatcallable overrides that choice, at the price of printing0.00for the tiny value. -
display.float_formataccepts any callable that maps a float to a string. The"{:,.2f}".formatform is a bound method, and a lambda works equally well. It applies to every float column, not just one. -
chop_thresholdchanges the printed value of1.234e-05to0.000000but keeps the number. Use it to hide floating-point noise such as1e-17in a matrix print. -
To format one column and not the others, convert it to strings in a copy, or use a
Styler(see Table Styling) which has its ownstyler.format.*options.
The compute, mode, io and plotting groups
Beyond display, the option groups below change how pandas computes or reads. Some of them are the most consequential settings in the library, and several changed meaning in pandas 3.
| Option | Default | Effect |
|---|---|---|
|
|
Use the Bottleneck library for some reductions when it is installed. |
|
|
Use numexpr to speed up large arithmetic and comparisons when it is installed. See Enhancing Performance. |
|
|
Make the numba engine the default for the methods that support |
|
|
New in pandas 3.1. The most worker threads parallel operations such as |
|
|
Show or hide |
|
|
Storage behind the |
|
|
Parquet engine used by |
|
|
SQL engine used by |
|
|
Excel engine per file format. |
|
|
The module that implements |
Source: Available options, and the descriptions printed by pd.describe_option() in pandas 3.1.0.
mode.max_threads is worth a measurement, because it is a good example of an option that changes speed without changing results. On the 300,000-row, 17-column CSV file used by Scaling to Large Datasets, the default C engine read the file in about 30 ms with the default thread count and about 85 ms with mode.max_threads set to 1 on one laptop. Treat the ratio as indicative: it depends on the CPU, the file and the columns.
import time
import pandas as pd
def clock(label, fn):
t0 = time.perf_counter()
out = fn()
print(f"{label:<34}{(time.perf_counter() - t0) * 1000:8.0f} ms")
return out
clock("read_csv, default threads", lambda: pd.read_csv("readings.csv"))
with pd.option_context("mode.max_threads", 1):
clock("read_csv, mode.max_threads = 1", lambda: pd.read_csv("readings.csv"))
Source: Available options.
Set mode.max_threads to a small number when pandas runs inside a larger parallel job (a web server with several workers, a joblib or multiprocessing pool, a scikit-learn grid search) so that its threads do not compete with the outer parallelism.
Choosing the string storage
mode.string_storage decides what backs the default str dtype. It does not change the dtype name, only the memory layout and speed.
import pandas as pd
with pd.option_context("mode.string_storage", "python"):
print(pd.Series(["a"]).array.dtype.storage)
with pd.option_context("mode.string_storage", "pyarrow"):
print(pd.Series(["a"]).array.dtype.storage)
Output:
python pyarrow
Source: Working with text data and Options and settings.
The str dtype and the separate "string" dtype with pd.NA are described on Text Data & the str Dtype.
Styler options
DataFrame.style has its own option group, styler.*. These affect only the HTML or LaTeX that a Styler renders, never the plain repr of the frame. They need the optional Jinja2 dependency.
import pandas as pd
df = pd.DataFrame({"price": [1234.5678, 0.5, 98765.4321], "name": ["a", None, "c"]})
pd.set_option("styler.format.precision", 1)
pd.set_option("styler.format.thousands", ",")
pd.set_option("styler.format.na_rep", "n/a")
html = df.style.to_html()
print("1,234.6" in html, "n/a" in html)
print(df) # the plain repr ignores styler.* options
pd.reset_option("styler")
Output:
True True
price name
0 1234.5678 a
1 0.5000 NaN
2 98765.4321 c
Source: Number formatting.
styler.render.max_elements (default 262144) caps how many data cells a Styler renders before it trims rows or columns, which prevents a browser from hanging on a huge table. styler.render.max_rows and styler.render.max_columns cap one dimension at a time.
Options that no longer do what old code expects
Options are where the pandas 3 migration is most visible, because older tutorials changed global settings to switch behaviour on or off. In pandas 3 several of those switches are gone or inert.
| Older advice | State in pandas 3.1 | What to do |
|---|---|---|
|
Deprecated and has no effect. Copy-on-Write is always on. Setting it emits a |
Delete the line. Read Copy-on-Write. |
|
Deprecated and has no effect. |
Rewrite the assignment as |
|
The |
Remove the opt-in. Use |
|
Removed in 3.0. |
Convert infinities explicitly with |
|
Deprecated and has no effect. |
Delete the line. |
|
Deprecated. |
Drop rows with |
Source: Options and settings and Migration guide for pandas 3.0.
The script below shows what happens when old code sets these options. Reading a deprecated option emits a warning too, not only setting it.
import warnings
import pandas as pd
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
print(pd.get_option("future.infer_string")) # True: the str dtype is the default
pd.set_option("mode.copy_on_write", True) # no effect, only a warning
pd.set_option("mode.chained_assignment", None)
for w in caught:
print(w.category.__name__, "-", str(w.message)[:90])
print(pd.get_option("mode.max_threads")) # None means min(CPUs, 6)
print(pd.get_option("compute.use_numba")) # False unless you opt in
print(pd.get_option("mode.performance_warnings"))
Output:
True Pandas4Warning - The 'future.infer_string' option is deprecated and will be removed in pandas 4.0. Inferring str dtype for Pandas4Warning - The 'mode.copy_on_write' option is deprecated. Copy-on-Write can no longer be disabled (it is always e Pandas4Warning - The 'mode.chained_assignment' option is deprecated. It has had no effect since pandas 3.0, None False True
Source: Options and settings.
The warning class is Pandas4Warning: it announces a change that will take effect in pandas 4.0. The deprecation policy is described on Installation & Versions. A test suite that turns warnings into errors with -W error will catch leftover option calls before an upgrade.
Setting options at startup
An option set inside a script lives for that process. To apply the same display settings to every interactive session, put the calls in an IPython startup script. A file such as ~/.ipython/profile_default/startup/00-pandas-options.py runs when IPython or a Jupyter kernel starts.
import pandas as pd
pd.set_option("display.max_columns", 30)
pd.set_option("display.width", 140)
pd.set_option("display.max_colwidth", 80)
Source: Setting startup options.
Keep startup options purely cosmetic. Anything that changes results, such as compute.use_numba or an alternative plotting.backend, belongs in the project code, where a colleague or a CI job will see it. A notebook that depends on a hidden startup file prints differently on another machine, which is a reproducibility problem of the same kind described on Jupyter Notebooks & JupyterLab.
Practical guidance
-
Prefer
option_contextoverset_optionin functions and in shared notebook cells. -
Use full option names. Partial regular expressions are a convenience for the prompt, not for code.
-
Changing display options never fixes a data problem. If a column looks wrong, inspect
dtypesand the values, not the formatting. -
Do not set an option to silence a warning from pandas 3. The removed options do nothing, so the warning stays or the behaviour is already fixed.
-
Keep a record of non-default options in notebooks that you share, as part of the environment description.
References
-
pandas.describe_option and the sibling reference pages for
get_option,set_option,reset_optionandoption_context