0

I have this dataframe:

enter image description here

And I'd like to unstack (or melt? or pivot?) the dataframe so that for every Coupon in the index, the SMM_diff gets its own column.

Something like:

                 SMM_diff_2.0    SMM_diff_2.5  ... rest of coupons
y_m
2020-05-01      -0.010935       -0.011007             ...
2019-02-01       0.007838       -0.007824
2021-04-01       0.029721       -0.004892
2020-07-01      -0.011197      -0.018712
2022-01-01       0.14557        -0.001675             ...
       ...              ...            
                         

I'm not really sure how to approach this problem to be honest, so any help would be appreciated. Thanks!

hulio_entredas
  • 675
  • 1
  • 12

1 Answers1

0

Wow, so simple: df['SMM_diff'].unstack(level = 1)

Does the trick.

enter image description here

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
hulio_entredas
  • 675
  • 1
  • 12