I have 2 dataframes. df1 is
DATE
2020-05-20
2020-05-21
and df2 is
ID NAME DATE
1 abc 2020-05-20
2 bcd 2020-05-20
3 ggg 2020-05-25
4 jhg 2020-05-26
I want to compare the values of df1 with df2, for eg: taking first value of df1 i.e 2020-05-20 and find it in df2 and filter it and show output and subset the filtered rows.
My code is
for index,row in df1.iterrows():
x = row['DATE']
if x == df2['DATE']:
print('Found')
new = df2[df2['DATE'] == x]
print(new)
else:
print('Not Found')
But I am getting the following error:
ValueError: The truth value of a series is ambigious. Use a.empty,a.bool(),a.item(),a.any()
Aucun commentaire:
Enregistrer un commentaire