Using python pandas find another data file and return the corresponding values

I have two data frames:

df1 as;

 Name Role Jim Accounts Sam Purchase Rhea Sales 

df2 as:

 Name Date Jim 1/1/2000 Jim 2/1/2000 Jim 3/1/2000 Sam 1/1/2000 Sam 2/1/2000 Rhea 1/1/2000 Rhea 2/1/2000 

I want to search for df1 and have output like:

  Name Date Role Jim 1/1/2000 Accounts Jim 2/1/2000 Accounts Jim 3/1/2000 Accounts Sam 1/1/2000 Purchase Sam 2/1/2000 Purchase Rhea 1/1/2000 Sales Rhea 2/1/2000 Sales 

I can not find a way to find Pandas.

+9
source share
1 answer

Use the merge function:

 df2.merge(df1) 
+13
source

Source: https://habr.com/ru/post/1489515/


All Articles