I want to populate the 'Salary' column in DataFrame1 (DF1) with the corresponding 'Salary' in DataFrame2 (DF2). These need to match on 'Team' AND 'Players'.
To note:
The Dataframes are: Not the same size. Not the same order.
import pandas as pd
#df 1:
nba_data = {'Team': ['Mavericks', 'Mavericks', 'Mavericks', '', 'NewYorkKnicks17','Houston Rockets', 'NewYorkKnicks17'],
'Players': ['Luka Doncic', 'Kristaps Porzingis', 'Jalen Brunson', 'Kristaps Porzingis', 'JR Smith',
'James Harden', 'Derrick Rose',],
'Salary': ['0', '0', '0','0', '0', '0', '0'],
'Coach': ['Rick Carlisle', 'Rick Carlisle', 'Steve Kerr', 'Phil Jackson', 'Tom Thibideou', '', '']}
nba_df1 = pd.DataFrame(nba_data)
nba_df1
#df2:
nba_data2 = {'Team': ['Mavericks', 'Mavericks', 'Mavericks', 'NewYorkKnicks17', 'NewYorkKnicks17', 'NewYorkKnicks17', 'Houston Rockets'],
'Players': ['Luka Doncic', 'Kristaps Porzingis', 'Steph Curry', 'JR Smith', 'Derrick Rose',
'Kristaps Porzingis', 'James Harden'],
'Salary': ['3m', '126m', '0','115m', '0', '20m', '1.5m'],
'Coach': ['Rick Carlisle', 'Rick Carlisle', 'Steve Kerr', '', 'Tom Thibideou', 'Phil Jackson', '']}
nba_df2 = pd.DataFrame(nba_data2)
nba_df2
Result desired = nba_df1 with the appropriate salaries populated (run the below):
nba_data3 = {'Team': ['Mavericks', 'Mavericks', 'Mavericks', '', 'NewYorkKnicks17','Houston Rockets', 'NewYorkKnicks17'],
'Players': ['Luka Doncic', 'Kristaps Porzingis', 'Jalen Brunson', 'Kristaps Porzingis', 'JR Smith',
'James Harden', 'Derrick Rose',],
'Salary': ['3m', '126m', '0','20m', '115m', '1.5m', '0'],
'Coach': ['Rick Carlisle', 'Rick Carlisle', 'Steve Kerr', 'Phil Jackson', 'Tom Thibideou', '', '']}
nba_df1_adjusted = pd.DataFrame(nba_data3)
Kindly note: this is not a tutorial. - it is a specific question and therefore not a duplicate of a general tutorial.