How to display all Pandas dataframe column names in Jupyter ?

Today we’ll learn about how to be able to show all column names on your Pandas Dataframe when displaying it in your Jupyter Notebook.

By default, Jupyter Notebook and other Python IDEs (such as PyCharm) display up to 20 columns. This is governed by the Pandas option display.max_columns.

Display all dataframe columns in Jupyter

Type the next couple of lines in a new Jupyter Python 3 Notebook:

import pandas as pd

# The result will be:


Seeing all available columns for a DataFrame in one line is as simple as typing the following code:

pd.set_option('display.max_columns', <numbers_of_columns>)

Replace the <number_of_columns> parameter with an integer value as needed. Example:

#Displays 40 columns
pd.set_option('display.max_columns', 40)

Other option is to use the following code:

#Displays all columns, might be tricky for very wide DataFrame
pd.set_option('display.max_columns', None)

Using pandas display.max_columns example

Define example DataFrame

import pandas as pd
import numpy as np

n = 100
cols = 25

#create test data
salaries = np.random.normal(120,12,n).round()
week = pd.date_range('2021-01-10', periods = n, freq = 'w')

hr = dict(week = week, avg_salary=salaries)
hr_df = pd.DataFrame(hr)

# create 25 additional columns
for i in range(1,cols,1):
    hr_df['Avg_'+ str(i)] = hr_df['avg_salary']/int(i)

#display the df

Here’s our DataFrame, note that the column headers rows is truncated by default as we are exceeding the default number of shown columns.

Showing all columns

As shown beforehand we can now go ahead and set the max displayed columns in Pandas:


# or alternatively for our case


Here’s the result, note that depending on your screen resolution you might need to use the scrollbar to view all data columns.

Additional learning