Is it possible in pandas to interpolate for missing values in multiindex dataframe. This example below does not work as expected:
arr1=np.array(np.arange(1.,10.,1.))
arr2=np.array(np.arange(2.,20.,2.))
df1=pd.DataFrame(zip(arr1,arr2,arr1+arr2,arr1*arr2),columns=['x','y','xplusy','xtimesy'])
df1.set_index(['x','y'],inplace=True)
df2=df1.reindex(index=zip(*df1.index.levels)+[(2,2),(3,2),(5,5)])
df2.sortlevel([0,1],inplace=True)
df2.interpolate(method='linear',inplace=True)
displays not what I expected in xplusy and xtimesy columns for added indices.
----------- ---- ---
(1.0, 2.0) 3 2
(2.0, 2.0) 4.5 5
(2.0, 4.0) 6 8
(3.0, 2.0) 7.5 13
(3.0, 6.0) 9 18
(4.0, 8.0) 12 32
(5.0, 5.0) 13.5 41
(5.0, 10.0) 15 50
(6.0, 12.0) 18 72
(7.0, 14.0) 21 98
(8.0, 16.0) 24 128
(9.0, 18.0) 27 162
----------- ---- ---