0

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.

2
  • 1
    df.set_index(['a','b'])? Commented Nov 6, 2017 at 4:46
  • what i mean is, i want the df.columns (the df.columns is a index object) to be a multi-index. df.set_index(['a','b']) just makes the df.index a multiindex. Commented Nov 6, 2017 at 5:04

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.