get column names pandas by index code example
Example 1: dataframe get index name
In [7]: df.index.name
Out[7]: 'Index Title'
In [8]: df.index.name = 'foo'
In [9]: df.index.name
Out[9]: 'foo'
In [10]: df
Out[10]:
Column 1
foo
Apples 1
Oranges 2
Puppies 3
Ducks 4
Example 2: python pandas return column name of a specific column
# Basic syntax:
list(df.columns)[column_number]
# This returns the column name of the column of interest