0

I have the following pandas dataframe with index titled my_index

my_index | Lunch | Dinner | 
---------|-------|--------|
Yes      |  100  | 300    | 
No       |  20   | 400    |

I am trying to reshape or pivot the dataframe so that the my_index becomes the column names and the row values appear as this:

The desired outcome will be:

 my_index | Yes | No
    ------|-----|---
    Lunch | 100 | 20
    Dinner| 300 | 400

I have tried using pivot_table and pivot but am stumped!

Any pointers in the right direction would be helpful!

Thank you in advance!

Beans On Toast
  • 903
  • 9
  • 25

1 Answers1

0
df = df.T 

Transposes the dataframe!

Beans On Toast
  • 903
  • 9
  • 25