python 2.7 - Average of median of a column in a list of dataframes -
i looking best way take average of median of column in list of data frames (same column name).
let's have list of dataframes list_df
. can write following for
loop required output. more interested in looking if can eliminate for
loop
med_arr = [] list_df = [df1, df2, df3] df in list_df: med_arr.append(np.median(df['col_name'])) np.mean(med_arr)
this done list comprehension:
list_df = [ df1, df2, df3 ] med_arr = [ np.median( df['col_name'] ) df in list_df ] np.mean(med_arr)
Comments
Post a Comment