How to show all columns' names on a large pandas dataframe?
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 = Nonepd.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())
To obtain all the column names of a DataFrame, df_data
in this example, you just need to use the command df_data.columns.values
.This will show you a list with all the Column names of your Dataframe
Code:
df_data=pd.read_csv('../input/data.csv')print(df_data.columns.values)
Output:
['PassengerId' 'Survived' 'Pclass' 'Name' 'Sex' 'Age' 'SibSp' 'Parch' 'Ticket' 'Fare' 'Cabin' 'Embarked']