Reputation: 2025
How can I get a list of the names of columns in an index?
Example:
df1 = pd.DataFrame(np.arange(20.).reshape((4,5)), columns=list('abcde'))
df1 = df1.set_index(['a','b'], drop=False)
a b c d e
a b
0 1 0 1 2 3 4
5 6 5 6 7 8 9
10 11 10 11 12 13 14
15 16 15 16 17 18 19
Is there a way to query df1 to get the index columns: "['a','b']"?
Upvotes: 0
Views: 912