I have a two datasets where I would like to match on the date and a specific column.
Data
df1
label date type1 stat1
111 7/1/2021 y n
222 8/1/2021 y n
333 9/1/2021 n y
df2
id date_1 type stat
111 7/1/2021 y n
222 7/20/2021 y n
333 7/30/2021 n y
Desired
id date type stat date_1 label type1 stat1
111 7/1/2021 y n 7/1/2021 111 y n
222 8/1/2021 y n
333 9/1/2021 n y
Doing
I figure I can treat as a string and do a left join. How would I join on
date value as well as the type column?
Any insight is appreciated.
df4 = df1.merge(df2, how='inner', left_on=["date","type1"], right_on=["date_1", "type"])
Although the dates are true dates
>Solution :
then it should be like this :
df3 = df1.merge(server, left_on=['date','type1'], right_on=['date_1','type'], how='left')