How to show all columns” names on a large pandas dataframe?

StackOverflow

I have a dataframe that consist of hundreds of columns, and I need to see all column names.

What I did:

In[37]:
data_all2.columns

The output is:

Out[37]:
Index(["customer_id", "incoming", "outgoing", "awan", "bank", "family", "food",
       "government", "internet", "isipulsa",
       ...
       "overdue_3months_feature78", "overdue_3months_feature79",
       "overdue_3months_feature80", "overdue_3months_feature81",
       "overdue_3months_feature82", "overdue_3months_feature83",
       "overdue_3months_feature84", "overdue_3months_feature85",
       "overdue_3months_feature86", "loan_overdue_3months_total_y"],
      dtype="object", length=102)

How do I show all columns, instead of a truncated list?

Answer rating: 318

You can globally set printing options. I think this should work:

Method 1:

pd.set_option("display.max_columns", None)
pd.set_option("display.max_rows", None)

Method 2:

pd.options.display.max_columns = None
pd.options.display.max_rows = None

This will allow you to see all column names & rows when you are doing .head(). None of the column name will be truncated.


If you just want to see the column names you can do:

print(df.columns.tolist())




Tutorials