Fill multi-index Pandas DataFrame with interpolation

后端 未结 1 1732
予麋鹿
予麋鹿 2020-12-19 10:49

I would like to bfill and ffill a multi-index DataFrame containing NaNs (in this case the ImpVol field) usin

相关标签:
1条回答
  • 2020-12-19 11:40

    I'd try to unstack the data frame at the OptionType level of index.

    df.unstack(level=1)
    

    This way you should obtain a single index dataframe which will have both call and put categories moved to columns. Maybe it's not the most elegant way of solving the problem, but it should work things out, not letting the put/call strikes to overlap.

    If multi index df is the most desirable one for further computations, you can restore the original format using stack method.

    0 讨论(0)
提交回复
热议问题