I have a DF:
| IDs |
|---|
| TIRL002 |
| GRUP003 |
| BUMB004 |
| TIRL002 |
| GRUP003 |
| BUMB004 |
I have another DF:
| Names | IDs |
|---|---|
| Tirone Lang | TIRL002 |
| GroupDB | GRUP003 |
| BumbEver | BUMB004 |
| GroupDB | GRUP003 |
| BumbEver | BUMB004 |
| Tirone Lang | TIRL002 |
That's what I want to do (kind of VLOOKUP function):
| IDs | Names |
|---|---|
| TIRL002 | Tirone Lang |
| GRUP003 | GroupDB |
| BUMB004 | BumbEver |
| TIRL002 | Tirone Lang |
| GRUP003 | GroupDB |
| BUMB004 | BumbEver |
I have a lot of these IDs and names (about 300) and I tried to pd.merge them and it works, but it changes the order of the values to alphabetical. How can I ignore this and stick to the correct order in my final DF?
import pandas as pd
df1 = pd.read_csv('1.csv')
df2 = pd.read_csv('2.csv')
result = pd.merge(df1, df2, on ='IDs', how ='inner')
print(result)