I have 2 dataframes, df1,and df2 as below.
df1
and df2
I would like to lookup "result" from df1 and fill into df2 by "Mode" as below format. Note "Mode" has become my column names and the results have been filled into corresponding columns.
also note that "ID" from df2 may not necessary equal to "ID" from df1.For example, I am only interested in 4 IDs (A01,A03,A04 and A05, no A02) while df1 may contain more IDs
I tried to use below code but it doesn't give me a good result.
merged_df = pd.merge(df2, df1,left_on = 'ID', right_on = 'ID', how='outer')
How can I do this?