0

I have this pandas dataframe:

product  espec   desc
   1     color   blue
   2     color   blue
   3     size      S
   2     size      M
   2     fabric  cotton
   1     size      S
...

And I need to transform into this one:

product   color   size  fabric
   1      blue     S      null
   2      blue     M    cotton
   3      null     S     null

I've already done using 'for' to go through the dataframe and construct another one, but as the original dataframe is to big and it is taking more than one hour. So, I read about the pandas functions pivot and pivot_table and I believe it could solve this problem easily. But I'm not getting the parameters right. It always into something strange.

Do anyone know a easy way to make this transformation?

C Bury
  • 3
  • 1
  • 3

0 Answers0