0

I am very new to pandas and am trying to figure out how to transform a dataframe by grouping by rows.. The column names need to be changed depending on data. Any help will be greatly appreciated. I added the image to show original vs transformed view.

here is an example of the data.

Original dataframe: a b c 111 2020 33.2 111 2021 48.3 111 2022 68.0 222 2020 32.2 222 2021 45.5 222 2022 57.2 333 2020 45.5 333 2021 78.4 333 2022 67.4

Transformed need to look like this:

a 2020_b 2021_b 2022_b 111 33.2 48.3 68.0 222 32.2 45.5 57.2 333 45.5 78.4 67.4

enter image description here

Praveena
  • 11
  • 3

0 Answers0