Written and maintained by CASRAI Editorial Board
Published
On this page
To display all columns of a pandas DataFrame, set the display option to unlimited with pd.set_option('display.max_columns', None), or scope the change to one block with pd.option_context('display.max_columns', None), or print the frame with df.to_string(), which ignores the column limit altogether. According to the pandas options documentation, a value of None for these limits means unlimited, and if the column limit is exceeded pandas switches to a truncated view. On wide research tables, such as survey exports with dozens of items, the output may still wrap across several blocks after you do this; that is controlled by a different option, display.width, covered below.
What pandas display options are used for in research
pandas is a Python library for data analysis; its PyPI page describes it as providing “powerful data structures for data analysis, time series, and statistics”. In research workflows, DataFrames hold survey responses, instrument exports, trial datasets and coded qualitative data, and these often have dozens or hundreds of columns. When you print such a frame in a terminal, script log or notebook, pandas shows only the first and last few columns and replaces the middle with an ellipsis (...) together with a shape line such as [3 rows x 31 columns].
That truncation protects your screen, but it is a risk when you are checking a dataset: a misnamed variable, a duplicated column or an unexpected encoding in a hidden middle column cannot be seen if it is never printed. Display settings change only how a frame is shown. They never delete, reorder or alter the data, so they are safe to use during data cleaning and when you want to document a variable list for a data management plan or codebook.
How to install or access pandas
The pandas installation page gives two supported routes. With pip, from PyPI: pip install pandas. With conda, from the conda-forge channel: conda install -c conda-forge pandas. To create a fresh conda environment with pandas, the same page shows conda create -c conda-forge -n name_of_my_env python pandas followed by conda activate name_of_my_env. Optional dependencies such as Excel support are installed with pip install "pandas[excel]". The PyPI page and the pandas documentation both list version 3.1.1 as current; the examples on this page were run on that version. If you work in notebooks, see the guide on Anaconda for Jupyter Notebook.
How to display all columns in pandas step by step
The following steps use a 100-row, 31-column table of simulated Likert-scale survey responses. The data are generated randomly for illustration (an illustrative composite, not real study data): one respondent_id column and thirty item columns named q01_item to q30_item.
- Build or load the frame. For example
import pandas as pdthendf = pd.read_csv('survey.csv'). If you need to construct a frame by hand, see creating a DataFrame in Python. - Check what the current limit is. Run
pd.get_option('display.max_columns'). In a plain Python script on pandas 3.1.1 this returned0. The pandas options documentation describesdisplay.max_columnsas being 0 in a terminal, where pandas auto-detects the available width, andNoneas unlimited. - Print the frame before any change.
print(df.head(3))showedrespondent_id q01_item q02_item ... q28_item q29_item q30_itemfollowed by[3 rows x 31 columns]: the middle columns are hidden behind the ellipsis. - Lift the column limit globally. Run
pd.set_option('display.max_columns', None). The change lasts until you reset it or the Python process ends. Printing again shows all 31 columns. - Or lift it only for one block. Use the context manager:
with pd.option_context('display.max_columns', None): print(df.head(3)). The pandas documentation states that option_context executes a code block with a set of options that revert to the prior settings after execution. After the block,pd.get_option('display.max_columns')returned0again in our test. - Or avoid global state entirely.
print(df.head(3).to_string())returns every column as a string.DataFrame.to_stringalso acceptsmax_colsto cap the number of columns,columnsto choose a subset andline_widthto set the wrap width. - Restore defaults when finished.
pd.reset_option('^display')resets every option whose name matches the pattern, which the documentation uses as its example for resetting all display options. To reset a single option, pass its full name, for examplepd.reset_option('display.max_columns').
All of these calls take effect on how a frame is printed, so run them before the print or display statement that you want to change. For related column-level tasks, such as removing columns you no longer want to see, read how to drop columns in pandas.
Setting several options at once
A common research setup is to show every column, raise the row limit and widen cells in the same call: with pd.option_context('display.max_columns', None, 'display.max_rows', 200, 'display.max_colwidth', None): print(df). The options documentation shows the same pattern, an alternating list of option name and value, for display.max_rows and display.max_columns, and notes that max_rows returns to its default (60) after the block ends.
How to read the output
When columns are hidden, the printed frame has an ellipsis column and a trailing line stating the shape, for example [3 rows x 31 columns]. The numbers in that line are the true dimensions, so you can always compare them with df.shape. Once display.max_columns is None, that ellipsis column disappears and the frame is printed in full.
A second thing you may see is a trailing backslash at the end of each line and the table continuing in another block underneath. In our run, with the column limit removed but the width left at 80, the 31 columns printed as several stacked blocks of 7 to 8 columns, each line ending in . This is not truncation: every column is present, wrapped across “pages”. The options documentation says display.expand_frame_repr (default True) controls this wrapping when the frame is wider than display.width (default 80), and that max_columns is still respected.
When both display.max_columns and display.width were set to None in a script, the first rows printed on a single very long line per row. That is useful for copying into a text file and not useful for reading on a narrow screen. Choose wrapped output for reading and a single long line only for machine handling; for a wide table you intend to share, writing to a file is usually better than printing.
The data table below lists the display options that interact, with the defaults named in the pandas documentation and the value observed in a test session.
Troubleshooting pandas display
I set max_columns to None but the columns still wrap
The wrapping comes from display.width and display.expand_frame_repr. Per the options documentation, display.width defaults to 80 and, when Python or IPython runs in a terminal, may be set to None so that pandas auto-detects the width. Setting display.expand_frame_repr to False stops the wrapped “pages” in favour of a single, wider table. Choose one: accept wrapping for narrow screens, or use df.to_string() and read the result in a text editor.
Cells end with three dots instead of the full text
That is display.max_colwidth, which defaults to 50 characters; longer text is cut with a “…” placeholder, and None means unlimited. It matters for free-text survey answers and open-ended coding fields. DataFrame.to_string has its own max_colwidth parameter.
Rows are hidden in the middle
Rows are governed separately by display.max_rows (default 60) and display.min_rows (default 10, the number shown when the frame exceeds max_rows). Setting display.max_rows to None shows every row; for a long table this can flood the screen, so prefer df.head(n) or a scoped option_context.
OptionError: Pattern matched multiple keys
pandas lets you pass a regular-expression pattern or an unambiguous substring in place of a full option name. A short pattern such as 'max' matches several options (display.max_colwidth, display.max_rows and display.max_columns) and raises an OptionError saying the pattern matched multiple keys; we reproduced this with pd.get_option('max'). The options documentation warns that the shorthand may break when new options are added, so write the full name such as display.max_columns in shared analysis code.
Settings leak into later cells or scripts
A global pd.set_option call stays in force for the rest of the session, including later notebook cells and any imported module that prints frames. Use pd.option_context in reusable code and reset with pd.reset_option when you finish.
Check the column list instead of printing the table
If you only need to confirm that variables are present and spelled correctly, list(df.columns) or df.columns.tolist() returns the names without any width or truncation issues, and df.shape returns the row and column counts. For missing values in those columns, see dropna in pandas.
Free alternatives to changing the global display option
pandas is open-source, and each of these routes uses only built-in pandas features. The table summarises where each is documented.
| Approach | What it does | Changes global state? |
|---|---|---|
pd.set_option('display.max_columns', None) |
Removes the column limit for every frame printed in the session | Yes, until reset or the process ends |
pd.option_context(...) |
Applies options inside a with block, then restores the earlier values |
No, reverts after the block |
df.to_string() |
Returns the whole frame as a string; accepts max_cols, columns, line_width, max_colwidth |
No |
df.to_html() |
Returns the frame as an HTML table; accepts columns, max_rows, max_cols |
No |
list(df.columns) |
Lists the column names only | No |
Because the first call is global and the others are not, the scoped forms are safer in code that other people will rerun. Once your wide table is readable, further steps such as applying a function across columns with apply or adding derived variables with pandas add column are covered elsewhere on this site.
Sources
Data: pandas display options that control how many columns and cells are printed
Original compilation of the pandas display options that interact when a wide DataFrame is printed, with the default stated in the pandas Options and settings documentation and, where the option was exercised, the value observed in a test session on pandas 3.1.1.
Period covered: pandas 3.1.1.
| Option | Documented default | What it controls | Observed in test |
|---|---|---|---|
| display.max_columns | 0 in a terminal (auto-detect); None = unlimited | Number of columns printed before the truncated view | Returned 0 in a script on pandas 3.1.1 |
| display.width | 80 | Character width of the output; None lets a terminal auto-detect | Left at 80, 31 columns wrapped into stacked blocks |
| display.expand_frame_repr | True | Wraps a frame wider than display.width across blocks | Wrapped output ends each line with a backslash |
| display.max_colwidth | 50 | Characters shown per cell before a ... placeholder; None = unlimited | Returned 50 |
| display.max_rows | 60 | Rows printed before truncation | Returned 60 |
| display.min_rows | 10 | Rows shown when a frame exceeds max_rows | Not tested separately |
| display.large_repr | truncate | Whether oversized frames print truncated or as a summary | Not tested separately |
Sources
- pandas documentation: Options and settings (accessed 2026-11-17)
- pandas documentation: DataFrame.to_string (accessed 2026-11-17)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







