Categories
Python Answers

How to pretty-print an entire Python Pandas Series or DataFrame?

Spread the love

To pretty-print an entire Python Pandas Series or DataFram, we use the print method in the pd.option_context with statement.

For instance, we write

with pd.option_context('display.max_rows', None, 'display.max_columns', None):
    print(df)

to call pd.option_context to set some options for printing.

We make Pandas display all the rows and columns with display.max_rows and display.max_columns.

And then we call print with df to print the values of the series or data frame.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *