How to display all rows of a Pandas DataFrame? 2

How to display all rows of a Pandas DataFrame?

To display all rows of a Pandas DataFrame, use the “head()” method with no arguments. This will show all rows of the DataFrame without any limitation. Alternatively, you can use the “display()” function from the IPython.display module to print all rows of the DataFrame. This can be useful for inspecting large datasets or for printing the entire contents of a DataFrame in a Jupyter Notebook.

Show All Rows of a Pandas DataFrame


You can force a Jupyter notebook to show all rows in a pandas DataFrame by using the following syntax:

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

This tells the notebook to set no maximum on the number of rows that are shown.

The following example shows how to use this syntax in practice.

Example: Show All Rows in Pandas DataFrame

Suppose we create a pandas DataFrame with 500 rows and 3 columns.

If we attempt to display the DataFrame in a Jupyter notebook, only the first five rows and last five rows will be shown:

import pandas as pd
import numpy as np

#create dataFrame with 500 rows and 3 columns
df = pd.DataFrame(index=np.arange(500), columns=np.arange(3))

#view dataFrame
df

To display all of the rows, we can use the following syntax:

#specify that all rows should be shown
pd.set_option('display.max_rows', None)

#view DataFrame
df

The results are too long to display in a single screenshot, but the Jupyter notebook does indeed display all 500 rows.

To reset the default display settings, we can use the following syntax:

pd.reset_option('display.max_rows')

If we attempt to display the DataFrame in the Jupyter notebook, only the first five rows and last five rows will be shown once again.

Cite this article

stats writer (2024). How to display all rows of a Pandas DataFrame?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-to-display-all-rows-of-a-pandas-dataframe/

stats writer. "How to display all rows of a Pandas DataFrame?." PSYCHOLOGICAL SCALES, 27 Jun. 2024, https://scales.arabpsychology.com/stats/how-to-display-all-rows-of-a-pandas-dataframe/.

stats writer. "How to display all rows of a Pandas DataFrame?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-to-display-all-rows-of-a-pandas-dataframe/.

stats writer (2024) 'How to display all rows of a Pandas DataFrame?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-to-display-all-rows-of-a-pandas-dataframe/.

[1] stats writer, "How to display all rows of a Pandas DataFrame?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How to display all rows of a Pandas DataFrame?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top