1

I need to reformat my dataframe to a simplified example below:

Original DF:

ColA    ColB   ColC
week1     cat     10
week1     dog      8
week2     cat      2
week2     dog     28
week3     cat     12
week3     dog      7

Desired DF:

NewCol1     CatVal    DogVal
 week1       10         8
 week2        2         28
 week3       12         7

Any suggestions are appreciated! Thanks!

dmd7
  • 605
  • 3
  • 8
  • 2
    `df.pivot(*df)` or `df.pivot(*df).add_suffix("Val").reset_index()` should do, for more intricate operations, please read the linked duplicate link – anky Apr 13 '21 at 17:54

0 Answers0