Two DataFrames (df1, df2), df1 has column ID and df2 has columns ID, flag1, flag2.
I want to merge two DataFrames where all the ID's in df1 should be taken along with flag1,flag2 values.
I have the following line of code.
df3=pd.merge(df1, df2, on=id, how='left')
The output of df3 shows column values only for ID, and there are no values for flag1 and flag2.
The expected result in df3 should be ID, flag1, flag2 with values for flag1 and flag2 from df2.
on='ID'? Also your merge code should be working as intended, unless there is no matched ID between the two dataframes.