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 –
Default limit on columns to be shown
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.
Highlighted programs for you
Flatiron School
Flatiron School
University of Maryland Global Campus
University of Maryland Global Campus
Creighton University
Creighton University
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:

You can see that the dataset has 23 columns but some of these columns have been skipped (denoted by …) on display.
Display all the columns in Jupyter Notebook
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:

You can see that now if we display the dataframe, all the columns are shown because we have updated the max column display settings.
Display more rows in Jupyter Notebook
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.