pandas
I have two data frames and want to do a nested loop.
I want to iterate of each row from df1 and select col1 (id) and col2.
Then, it will take the ID and iterate through df2 and check if the row has the same ID and then compare date column from df1 with date column in df2
if col2 in df1 is less than col3 in df2, it will return True and append that to the row of df1.
if col2 < col3; return True else return False
df1
col1 col2 col3 col4
01 01/01/2018 S True
02 11/21/2018 F False
03 04/03/2018 C True
df2
col1 col2 col3
01 10/01/2018 A
02 01/01/2018 A
02 01/31/2018 F
02 10/01/2018 D
02 09/01/2018 V
03 02/01/2018 W
03 07/01/2018 X
Aucun commentaire:
Enregistrer un commentaire