0

I currently have a dataframe that looks like this:

       A       B       C
0   0.6875  0.1923  0.2300
1   0.3887  0.1923  0.5300
2   0.6061  0.2576  0.2474

I'm looking for a way to and make the first column the same as the header row, so the new dataframe would look like this:

       A       B       C
A   0.6875  0.1923  0.2300
B   0.3887  0.1923  0.5300
C   0.6061  0.2576  0.2474

Can anyone please help me regarding this?

1
  • 3
    df.index = df.columns.. ? Commented Sep 8, 2020 at 14:04

1 Answer 1

2

This should do it:

df.set_index(df.columns, inplace=True)
print(df)

        A       B       C
A  0.6875  0.1923  0.2300
B  0.3887  0.1923  0.5300
C  0.6061  0.2576  0.2474
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @NYC Coder
You can mark this as the answer if it worked for you.

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.