I have a dataframe that consist of hundreds of columns, and I need to see all column names.
What I did:
JavaScript
x
3
1
In[37]:
2
data_all2.columns
3
The output is:
JavaScript
1
11
11
1
Out[37]:
2
Index(['customer_id', 'incoming', 'outgoing', 'awan', 'bank', 'family', 'food',
3
'government', 'internet', 'isipulsa',
4
5
'overdue_3months_feature78', 'overdue_3months_feature79',
6
'overdue_3months_feature80', 'overdue_3months_feature81',
7
'overdue_3months_feature82', 'overdue_3months_feature83',
8
'overdue_3months_feature84', 'overdue_3months_feature85',
9
'overdue_3months_feature86', 'loan_overdue_3months_total_y'],
10
dtype='object', length=102)
11
How do I show all columns, instead of a truncated list?
Advertisement
Answer
You can globally set printing options. I think this should work:
Method 1:
JavaScript
1
3
1
pd.set_option('display.max_columns', None)
2
pd.set_option('display.max_rows', None)
3
Method 2:
JavaScript
1
3
1
pd.options.display.max_columns = None
2
pd.options.display.max_rows = None
3
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:
JavaScript
1
2
1
print(df.columns.tolist())
2