how do i compare date columns in two different data frames based on the same ID

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



how do i compare date columns in two different data frames based on the same ID



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 col2 in df2, it will return True and append that to the row of df1.


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





if col2 in df1 is less than col3 in df2, how do you compare a date to a character?
– RafaelC
3 hours ago



if col2 in df1 is less than col3 in df2,





sorry it was a typo. i'm trying to compare dates. however i would specify the date column to compare.
– Vu Le
3 hours ago










By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered