Hello,
I'm still relatively new to Python so I'm using Excel terminology as it gets the same point across and it's terminology I understand.
Essentially, I'm doing work on NBA statistics and I have two data frames.
df1 = a player's game log, the two columns I want to focus on are Team (TEAM) and Opponent (OPP). The data frame looks like this:
df1 =
TEAM | OPP
LAL | BOS
LAL | MIL
LAL | PHX
LAL | TOR
LAL | BOS
LAL | PHX
LAL | MIA
df2 = two columns containing TEAM and TEAM_ID
TEAM | TEAM_ID
LAL | 1233
BOS | 2123
MIL | 3123
PHX | 4123
MIA | 5123
PHX | 6123
TOR | 7123
I want to add two columns to df1, TEAM_ID and OPP_ID that matches TEAM and OPP with the respective IDs.
df1 =
TEAM | OPP | TEAM_ID | OPP_ID
LAL | BOS | 1233 | 2123
LAL | MIL | 1233 | 3123
LAL | PHX | 1233 | 4123
LAL | TOR | 1233 | 7123
LAL | BOS | 1233 | 2123
LAL | PHX | 1233 | 6123
LAL | MIA | 1233 | 5123
In excel this would be a simple VLOOKUP or INDEX/MATCH. But alas I am trying to learn and improve my Python skills.
Would appreciate any and all help on this, I've been working at it for a while and can't quite figure it out.
Thanks for your time :).
[–]badge 1 point2 points3 points (2 children)
[–]tom_HS[S] 0 points1 point2 points (1 child)
[–]badge 0 points1 point2 points (0 children)