Skip to main content

Python Pandas: How to Show All Columns of a Pandas DataFrame

When working with wide datasets in Pandas, the library automatically truncates the display, replacing middle columns with ... to keep the output manageable. While this default behavior is helpful for small previews, it becomes frustrating when you need to inspect every column in your DataFrame.

This guide covers multiple ways to show all columns, rom changing global display settings to listing column names and printing the full DataFrame as a string.

Why Pandas Hides Columns by Default

By default, Pandas limits the number of displayed columns to 20. If your DataFrame has more columns than this threshold, Pandas truncates the output and shows ellipses (...) in the middle:

import pandas as pd

df = pd.DataFrame({f'col_{i}': [i] for i in range(30)})
print(df)

Output:

   col_0  col_1  col_2  col_3  col_4  ...  col_25  col_26  col_27  col_28  col_29
0 0 1 2 3 4 ... 25 26 27 28 29

[1 rows x 30 columns]

Columns 3 through 26 are hidden. The following methods let you override this behavior.

Using pd.set_option() to Show All Columns

The most common approach is to change the display.max_columns option using pd.set_option(). Setting it to None removes the column limit entirely:

import pandas as pd

df = pd.DataFrame({f'col_{i}': [i] for i in range(30)})

# Remove the column display limit
pd.set_option('display.max_columns', None)

print(df)

Output:

   col_0  col_1  col_2  col_3  col_4  col_5  col_6  col_7  col_8  col_9  \
0 0 1 2 3 4 5 6 7 8 9

col_10 col_11 col_12 col_13 col_14 col_15 col_16 col_17 col_18 \
0 10 11 12 13 14 15 16 17 18

col_19 col_20 col_21 col_22 col_23 col_24 col_25 col_26 col_27 \
0 19 20 21 22 23 24 25 26 27

col_28 col_29
0 28 29

All 30 columns are now visible.

Useful Display Options to Combine

You may also want to adjust related settings for a better viewing experience:

import pandas as pd

# Show all columns
pd.set_option('display.max_columns', None)

# Increase the display width so columns don't wrap to the next line
pd.set_option('display.width', None)

# Show more rows if needed
pd.set_option('display.max_rows', 100)

# Prevent long column content from being truncated
pd.set_option('display.max_colwidth', None)

Resetting Options to Default

After inspecting your data, you may want to restore the default display behavior:

# Reset a specific option
pd.reset_option('display.max_columns')

# Or reset all display options at once
pd.reset_option('all')
tip

Use pd.reset_option('display.max_columns') when you're done inspecting wide DataFrames. Keeping max_columns set to None globally can make routine output overwhelming, especially in notebooks.

Using pd.option_context() for Temporary Changes

If you only need to show all columns for a single operation without permanently changing the global settings, use pd.option_context() as a context manager:

import pandas as pd

df = pd.DataFrame({f'col_{i}': [i * 2] for i in range(25)})

# Temporarily show all columns, only within this block
with pd.option_context('display.max_columns', None, 'display.width', None):
print(df)

# Outside the block, the default settings are restored automatically
print(df) # This will truncate columns again if there are too many

Output (inside context):

   col_0  col_1  col_2  col_3  col_4  ...  col_22  col_23  col_24
0 0 2 4 6 8 ... 44 46 48

Output (outside context):

   col_0  col_1  col_2  ...  col_22  col_23  col_24
0 0 2 4 ... 44 46 48

This approach is cleaner than setting and resetting options manually and is especially useful in Jupyter notebooks where global changes persist across cells.

Using df.columns to List All Column Names

If you don't need to see the data itself but just want to know what columns exist, use the .columns attribute:

import pandas as pd

df = pd.DataFrame({
'name': ['Alice'],
'age': [30],
'city': ['New York'],
'email': ['alice@example.com'],
'salary': [75000]
})

print(df.columns)

Output:

Index(['name', 'age', 'city', 'email', 'salary'], dtype='object')

For a cleaner list format, convert it to a Python list:

print(df.columns.tolist())

Output:

['name', 'age', 'city', 'email', 'salary']

This is particularly useful when you need to programmatically check for a column's existence or iterate over column names.

Using df.to_string() to Display All Columns and Rows

The to_string() method converts the entire DataFrame into a plain string with no truncation of rows or columns:

import pandas as pd

df = pd.DataFrame({f'col_{i}': range(5) for i in range(25)})

print(df.to_string())

Output:

   col_0  col_1  col_2  col_3  col_4  col_5  col_6  col_7  col_8  col_9  col_10  col_11  col_12  col_13  col_14  col_15  col_16  col_17  col_18  col_19  col_20  col_21  col_22  col_23  col_24
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
warning

Use to_string() with caution on large datasets. A DataFrame with thousands of rows and dozens of columns will produce an enormous string that can freeze your terminal or notebook. For large datasets, consider combining it with .head() or .tail():

print(df.head(10).to_string())

Using df.info() to Get a Column Overview

If you want a quick summary of all columns - including their data types and non-null counts - without printing the actual data, use df.info():

import pandas as pd

df = pd.DataFrame({
'name': ['Alice', 'Bob', None],
'age': [30, 25, 35],
'city': ['New York', 'London', 'Tokyo'],
'score': [88.5, None, 92.0]
})

df.info()

Output:

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3 entries, 0 to 2
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 name 2 non-null object
1 age 3 non-null int64
2 city 3 non-null object
3 score 2 non-null float64
dtypes: float64(1), int64(1), object(2)
memory usage: 228.0+ bytes

This method always shows every column regardless of display settings, making it a reliable way to inspect wide DataFrames.

Quick Reference Summary

MethodWhat It ShowsPermanent ChangeBest For
pd.set_option('display.max_columns', None)All columns in outputYes (until reset)Exploratory analysis in scripts
pd.option_context(...)All columns within a blockNo (temporary)One-off inspection in notebooks
df.columns.tolist()Column names onlyN/AChecking column names programmatically
df.to_string()Full DataFrame as a stringN/APrinting small-to-medium DataFrames
df.info()Column names, types, null countsN/AQuick structural overview

By choosing the right method for your situation, you can efficiently inspect wide Pandas DataFrames without losing visibility into any of your data's columns.