Show all columns of Pandas DataFrame
Last Updated :
22 Apr, 2025
Pandas sometimes hides some columns by default if the DataFrame is too wide. To view all the columns in a DataFrame pandas provides a simple way to change the display settings using the pd.set_option() function. This function allow you to control how many rows or columns are displayed in the output.
Syntax: pd.set_option('display.max_columns', None)
By setting display.max_columns to None Pandas will show all columns in the DataFrame.
1. Displaying All Columns in a DataFrame
To limit the number of columns to display, pandas replaces middle columns with an ellipsis (...). To display all column we can use pd.set_option("display.max_columns", None). We will be using creditcard.csv
Python
import pandas as pd
df = pd.read_csv("creditcard.csv")
pd.set_option('display.max_columns', None)
df
Output:
The dataset contains 31 columns and all the columns are displayed using pd.set_option() methodIf you no longer need to display all columns and want to revert the display settings to the default behavior pd.reset_option() method is used:
Python
pd.reset_option('display.max_columns')
df
Output:
Dataset using pd.reset_option()2. Manually Listing All Column Names of Pandas DataFrame
If you only need to inspect the column names without displaying the entire DataFrame you can list all the columns using df.columns
:
Python
Output:
Index(['Time', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'V10',
'V11', 'V12', 'V13', 'V14', 'V15', 'V16', 'V17', 'V18', 'V19', 'V20',
'V21', 'V22', 'V23', 'V24', 'V25', 'V26', 'V27', 'V28', 'Amount',
'Class'],
dtype='object')
3. Displaying All Columns by Adjusting Column Width
When working with categorical data you may face an issue where the data in the columns is not fully visible due to the default maximum column width. To fix this we can increase the column width using pd.set_option('display.max_colwidth', 500, here 500 means columns width. You can download dataset from here.
Python
import pandas as pd
df = pd.read_csv('data.csv')
pd.set_option('display.max_colwidth', 500)
df
Output:
Displaying All Columns by Adjusting Column WidthBy using these methods we can see all columns of Pandas dataframe.
Similar Reads
How to Show All Columns of a Pandas DataFrame? Pandas limit the display of rows and columns, making it difficult to view the full data, so let's learn how to show all the columns of Pandas DataFrame. Using pd.set_option to Show All Pandas ColumnsPandas provides a set_option() function that allows you to configure various display options, includi
2 min read
Pandas DataFrame.columns In Pandas, DataFrame.columns attribute returns the column names of a DataFrame. It gives access to the column labels, returning an Index object with the column labels that may be used for viewing, modifying, or creating new column labels for a DataFrame.Note: This attribute doesn't require any param
2 min read
Add zero columns to Pandas Dataframe Prerequisites: Pandas The task here is to generate a Python program using its Pandas module that can add a column with all entries as zero to an existing dataframe. A Dataframe is a two-dimensional, size-mutable, potentially heterogeneous tabular data.It is used to represent data in tabular form lik
2 min read
Add column names to dataframe in Pandas Sometimes, Pandas DataFrames are created without column names, or with generic default names (like 0, 1, 2, etc.). Let's learn how to add column names to DataFrames in Pandas. Adding Column Names Directly to columns Attribute The simplest way to add column names is by directly assigning a list of co
3 min read
Count number of rows and columns in Pandas dataframe In Pandas understanding number of rows and columns in a DataFrame is important for knowing structure of our dataset. Whether we're cleaning the data, performing calculations or visualizing results finding shape of the DataFrame is one of the initial steps. In this article, we'll explore various ways
3 min read
How to rename columns in Pandas DataFrame In this article, we will see how to rename column in Pandas DataFrame. The simplest way to rename columns in a Pandas DataFrame is to use the rename() function. This method allows renaming specific columns by passing a dictionary, where keys are the old column names and values are the new column nam
4 min read