I want to introduce the contents of one df to another but as a list based on ID. I know to merge based on ID but I do not want duplicate rows for ID in the new dataframe. How do I get this done?
data1 = {'ID': ['AB01','AB02'],
'Name': ["toyota", "honda"],
'Age':[21,22]
}
df1 = pd.DataFrame.from_dict(data1)
data2 = {'ID': ['AB01','AB01','AB03','AB03'],
'Type': ["C",np.nan,"X","S"],
'Score':[87,98,45,82]
}
df2 = pd.DataFrame.from_dict(data2)
The result should look like this

