Display all columns of a pandas dataframe in jupyter notebook

Show all columns of Pandas DataFrame in Jupyter Notebook

If you are working with datasets containing a large number of columns, it can very well happen that only some of the columns are shown when displaying the dataframe or a section of it. In this tutorial, we’ll look at how to show all the columns of a pandas dataframe in a jupyter notebook.

If you prefer a video tutorial over text, check out the following video detailing the steps in this tutorial –

By default, a pandas dataframe displays a limited number of columns. You can check this with the following syntax:

import pandas as pd
pd.get_option("display.max_columns")

Output:

20

Depending on your pandas version and settings, you may get a different number. In our case, the result turned out to be 20. That is, if a dataframe has more than 20 columns, it will skip a few columns when displaying the dataframe.

Let’s read the rain in Australia dataset in a jupyter notebook. We read the dataset from a CSV file saved locally. This is how the dataset looks if we display the first five rows in jupyter notebook.

df = pd.read_csv("weatherAUS.csv")
df.head()

Output:

Dataframe displayed with skipped columns

You can see that the dataset has 23 columns but some of these columns have been skipped (denoted by …) on display.

📚 Data Science Programs By Skill Level

Introductory

Intermediate ⭐⭐⭐

Advanced ⭐⭐⭐⭐⭐

🔎 Find Data Science Programs 👨‍💻 111,889 already enrolled

Disclaimer: Data Science Parichay is reader supported. When you purchase a course through a link on this site, we may earn a small commission at no additional cost to you. Earned commissions help support this website and its team of writers.

To show all the columns of a pandas dataframe in jupyter notebook, you can change the pandas display settings. Let’s go ahead and set the max_columns display parameter to None so that all the columns are displayed. You can use the pandas set_option() function to alter such configurations.

# settings to display all columns
pd.set_option("display.max_columns", None)
# display the dataframe head
df.head()

Output:

Dataframe displayed with all the columns

You can see that now if we display the dataframe, all the columns are shown because we have updated the max column display settings.

You can also similarly change the display settings to show more rows when printing/displaying the dataframe. For example, to display all the rows of a pandas dataframe, set the max_rows display option to None. The following is the syntax:

pd.set_option("display.max_rows", None)

With this, we come to the end of this tutorial. The code examples and results presented in this tutorial have been implemented in a Jupyter Notebook with a python (version 3.8.3) kernel having pandas version 1.0.5


Subscribe to our newsletter for more informative guides and tutorials.
We do not spam and you can opt out any time.


Author

  • Piyush Raj

    Piyush is a data professional passionate about using data to understand things better and make informed decisions. He has experience working as a Data Scientist in the consulting domain and holds an engineering degree from IIT Roorkee. His hobbies include watching cricket, reading, and working on side projects.

Scroll to Top