Could you please help me with joining two DataFrames.
I have two DataFrames.
df1:
index val1 val2
--------------------
1 str1 abc1
2 str2 abc2
3 str3 abc3
4 str4 abc9
5 str5 abc4
df2:
index val2
------------
1 abc1
2 abc2
4 abc3
5 abc4
9 abc5
I need to create a DataFrame based on the previous two with a left join by two columns. Columns index and val2 have the same names in both DataFrames. The result of df3 should look like this:
index val1 val2 val3
----------------------------
1 str1 abc1 1
2 str2 abc2 1
3 str3 abc3 NaN
4 str4 abc9 NaN
5 str5 abc4 1
Indexes from df2 that are not present in df1 should be dropped, if an index in df1 has the same val2 as in df2 then 1 should be added to a new column val3, else: NaN.
Huge thanks in advance!
index
a column named index or the actual index of theDataFrame
? – ALollz