pandas get column name by index code example
Example 1: get column number in dataframe pandas
# PANDAS: get column number from colomn name
dataframe.columns.get_loc("<col_name>")
Example 2: pd dataframe get column names
lst = data.columns.values # data is dataframe
Example 3: 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