Reshaping Long Data To Wide In Python (pandas)
I'm trying to reshape my long data to a wide format. The data currently looks like:  OBS . date . TICKER . RET  1 . 20050131 . AAPL . 0.02 2 . 20050231 . AAPL . 0.01 3 . 20050131 .
Solution 1:
You can pivot your dataframe:
df.pivot(index='TICKER', columns='date', values='RET')
date    20050131  20050231
TICKER                    
AAPL        0.02      0.01
GOOG        0.05      0.03
Post a Comment for "Reshaping Long Data To Wide In Python (pandas)"