Let dfList = [df0, df1, df2, df3, df4]
be a list of pandas dataframes with the same columns and index.
I would like to average them, but some dataframes are outliers for some rows.
I have a list of non-outliers: myList = [ [0,1] , [1,2,3], [0,2,4] ]
showing which dataframes should be averaged for each row.
So,
result.iloc[0,:] = average( df0.iloc[0,:] , df1[0,:] )
result.iloc[1,:] = average( df1.iloc[1,:] , df2.iloc[1,:] , df3.iloc[1,:] )
result.iloc[2,:] = average( df0.iloc[2,:] , df2.iloc[2,:] , df4.iloc[2,:] )
How can I calculate the above described average in terms of dfList
and myList
?