Explain

How do I expand the output display to see more columns of a Pandas DataFrame?

By default, Pandas truncates columns in the console or Jupyter Notebook to keep the output view compact. If you want to see all columns of a DataFrame, here are the most common ways:

1. Use pd.set_option to Display All Columns

import pandas as pd

# Show all columns
pd.set_option("display.max_columns", None)

# Optionally, control the display width
pd.set_option("display.width", None)

# Now printing a DataFrame will display all columns
df = pd.DataFrame({
    "col1": [1, 2, 3],
    "col2": [4, 5, 6],
    "col3": [7, 8, 9],
    "col4": [10, 11, 12]
})
print(df)
  • display.max_columns: Setting to None means “unlimited columns.”
  • display.width: Setting to None tells Pandas to autodetect the best width for your console.

2. Reset Options Later If Desired

If you’d like to revert to default Pandas display settings:

pd.reset_option("display.max_columns")
pd.reset_option("display.width")

Recommended Courses

3. Jupyter Notebook Display

In a Jupyter environment, these settings also apply. Additionally, you can use:

from IPython.display import display
display(df)

to render the DataFrame in a scrollable table (depending on your Jupyter theme and version).

4. df.to_string() for String Output

For a quick snapshot without display truncation:

print(df.to_string())

This prints the entire DataFrame (all rows and columns) as text, ignoring default truncation.

Next Steps: Strengthen Your Python Skills

To get the most out of Python and Pandas, you’ll want a solid foundation. Grokking Python Fundamentals by DesignGurus.io is an excellent course to deepen your understanding of Python 3 features, best practices, and coding patterns—ensuring your data analysis and manipulation skills shine.

With these display settings (and enhanced Python knowledge), you’ll be able to inspect large or wide DataFrames in a more convenient and informative way. Happy data exploration!