'Trying to do a Vlookup with a value of another column as a column number - Python [duplicate]
Got 2 Dataframes
df1
| City | Number |
|---|---|
| LON | 1 |
| NYC | 2 |
| TOK | 3 |
df2
| City | 1 | 2 | 3 |
|---|---|---|---|
| LON | A | D | G |
| NYC | B | E | H |
| TOK | C | F | I |
What I'm trying to do is add a column to the end of df1 which would use the 'Number' Value as a column header for Df2
So for example The new column 'Letter' would:
-lookup TOK & 3 from df1 in df2 and return the Value I -lookup LON & 1 from df1 in df2 and return the Value A
New df1:
df1
| City | Number | Letter |
|---|---|---|
| LON | 1 | A |
| NYC | 2 | E |
| TOK | 3 | I |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
