Q&A library Python

How do I stop pandas truncating my DataFrame output with dots?

Python Beginner displayoptionspandas

Short answer

Pandas truncates wide or long output for readability. Raise display.max_columns and max_rows to see more, ideally inside a context manager so the change does not leak.

The short version

Pandas hides columns and rows beyond a limit and shows dots instead. Raise display.max_columns and display.max_rows to see more. Use pd.option_context so the change applies only where you need it, rather than leaking into the rest of your session.

Setting the options

import pandas as pd

pd.set_option("display.max_columns", 50)
pd.set_option("display.max_rows", 200)
pd.set_option("display.width", 200)          # total line width before wrapping

display.width matters as much as max_columns on a wide frame: even with enough columns allowed, a narrow width forces the output to wrap awkwardly.

Scoping the change

A global set_option affects everything afterwards, which is rarely what you want and can make later output unreadable. option_context limits it to a block.

with pd.option_context("display.max_rows", None):
    print(df)     # prints every row, only here

Passing None means no limit. Be careful: on a million-row frame, that will try to print a million rows.

Resetting

pd.reset_option("display.max_columns")
pd.reset_option("all")                   # everything back to defaults

Other useful display options

pd.set_option("display.float_format", "{:,.2f}".format)   # readable numbers
pd.set_option("display.max_colwidth", 100)                 # stop truncating long text

float_format affects only the display, not the stored values, which is the right way to make output readable without corrupting your data.

The better habit for wide frames

Rather than forcing a hundred columns onto the screen, look at the parts you care about.

df.head()                          # a few rows
df.dtypes                          # what the columns are
df[["city", "amount"]].head()      # just the columns of interest
df.T.head(30)                      # transpose: columns become rows, easier to scan

The transpose trick is genuinely useful for a wide frame with few rows, because it turns an unreadable horizontal sprawl into a scannable vertical list.

Truncation is a feature

The defaults exist because printing a large frame to a terminal is slow and useless. If you find yourself constantly raising the limits, that is usually a sign you should be inspecting the data differently: filtering to the rows that matter, selecting the columns that matter, or writing the result to a file and opening it properly.

For a real report

Do not screenshot a terminal. Use the Styler to produce formatted HTML or Excel, or write the frame to a file. The display options are for exploration; a table anyone else will read deserves a proper rendering.

Need this solved on your own data?

The library is free and always will be. When the problem is bigger than an answer, we take on the work.

Start a project