I have two tables for mean and std, I would like to calculate the maximum over some columns for the mean table, And I would like to get corresponding rows for the std table.
mean_df = pd.read_csv(r'./csvs/mean.csv')
std_df = pd.read_csv(r'./csvs/std.csv')
#mean_df, std_df are of same size
grouped_df = mean_df.groupby(['alpha', 'beta'])
columns = ['val']
max_df = grouped_df[columns].agg(['max'])
# Here i want the corresponding std_max_df table for the max_df. i.e., for every max calculated from mean, i want the std of that max in a new table.
For example:
input mean_df is
alpha beta gamma val
1 2 3 100
4 6 8 200
1 2 9 400
4 6 7 500
3 5 8 600
input std_df is
alpha beta gamma val
1 2 3 300
4 6 8 500
1 2 9 100
4 6 7 700
3 5 8 900
output will be
alpha beta gamma max_mean_val corresp_std_val
1 2 9 400 100
4 6 7 500 700
3 5 8 600 900