2

I have a dataframe:

    c1 c2  c3
0   1  A  11
1   1  B  12
2   2  A  21
3   2  B  22

Now I want to transform it to a new dataframe like

    c1   A   B
0   1  11  12
1   2  21  22

How can I achieve this with pandas?

tomsheep
  • 253
  • 1
  • 3
  • 7

1 Answers1

0

I found the answer in another question: python-pandas-convert-rows-as-column-headers. Just use pivot_table

Community
  • 1
  • 1
tomsheep
  • 253
  • 1
  • 3
  • 7