user40780
user40780

Reputation: 1920

pandas make column index a multiindex object

using

pd_now.set_index("a")

We could make column "a" adding to the index of the "row index", making "row index" a multiindex object

However, I did not find any way to add a row "b" to the "column index", making "column index" a multiindex object. Did I miss anything? Thank you.

Upvotes: 0

Views: 77

Answers (1)

BENY
BENY

Reputation: 323226

Using T and set_index

df.T.set_index(['a','b']).T

If you need add one

df.T.set_index('b',append=True).T

Upvotes: 1

Related Questions