I'm trying to make an option T-table. I have a pandas dataframe like this:
name contract optionName call_or_put IV
0 Crude Oil CL2009 CL2009C42 call 51.25%
1 Crude Oil CL2009 CL2009P42 put 52.13%
2 Gold GC2009 GC2009C1900 call 20%
3 Gold GC2009 GC2009P1900 put 22%
And I would like to change it to like this:
name contract call IV_call put IV_put
0 Crude Oil CL2009 CL2009C42 51.25% CL2009P42 52.13%
1 Gold GC2009 GC2009C1900 20% GC2009P1900 22%
I'm thinking to seperate the df to two dataframes, and use combine_first. But I haven't been able to make it work. Any ideas? Thanks in advance.
call_or_putcolumn hasput, you want to keep that row?