How do I combine two dataframes on two columns?
With Python and Pandas, you can join on 2 variables by using something like:
df=pd.merge(df,df2,how="left",on=['Date','About']) # can be how="left" or "inner","right","outer"
I have two df's: one has a date in the first column: all dates of the last three years and the second column are names of participants, other columns are information.
In the second df, I have some dates on which we did tests in the first column, then second column the names again and more columns information.
I would like to combine the two dateframes that in the first dataframe the information from the second will be added but for example if we did one test on 2-9-2020 and the same test for the same person on 16-9-2022 then from 2-9-202 until 16-9-2022 i want that variable and after that the other.
I hope it's clear what i mean.
i tried
data.merge(data_2, on='Date' & 'About')
but that is not possible to give two columns for on.