Home >Backend Development >Python Tutorial >How Can I Expand Pandas DataFrame Output to Display More Columns and Rows?

How Can I Expand Pandas DataFrame Output to Display More Columns and Rows?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-14 04:33:14599browse

How Can I Expand Pandas DataFrame Output to Display More Columns and Rows?

Expanding Pandas DataFrame Display Output

To expand the output display of your Pandas DataFrame to view more columns, you can use the pandas.set_option() function:

import pandas as pd

pd.set_option('display.max_columns', 500)

This sets the maximum number of columns to display in the output to 500.

Other Options

In addition to display.max_columns, you can also adjust other display options:

  • display.max_rows: Sets the maximum number of rows to display.
  • display.width: Sets the width of the output in characters.
  • display.max_colwidth: Sets the maximum width of each column (to avoid truncation).

Auto-Detection

By default, Pandas attempts to auto-detect the size of your terminal window. If the output cannot fit on the screen, it will switch to a summary view. You can disable auto-detection by setting display.width = 0.

Older Pandas Versions

For Pandas versions before 0.23.4, you can use the deprecated pandas.set_printoptions() function instead of pandas.set_option():

pd.set_printoptions(max_columns=500)

The above is the detailed content of How Can I Expand Pandas DataFrame Output to Display More Columns and Rows?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn