Jul-07-2021, 05:30 PM
I am new to python. I have two panda dataframes, they need to be merged conditionally.
group= df.groupby(['index1', 'index2'])['counts'].mean() for index, value in group.items(): final_df.loc[(final_df['index1'] == index[0]) & (final_df['index2'] == index[1]), 'result'] = valueFor small data sets, above code works just fine, but for a very large dataset, the for loop would take many many hours to complete. Is there any alternative for doing the above task much faster?