It can be easily done in Excel with index and match functions. But if you want to do it in python/pandas, I'd suggest you to
- import your excel sheet,
- merge the dataframes and then, (if you wish),
- export the new dataframe to excel:
import pandas as pd
excel = pd.read_excel("/your pathway/your excel file name.xlsx", header=0, usecols="A")
excel = pd.merge(
excel,
json,
on=["Symbol"],
how="left"
)
excel.to_excel("/your pathway/new file name.xlsx")
Just to test this solution, see the code below:
# Creating your Json dataframe
json_dict = {'Token': {0: 'w', 1: 'v', 2: 'x', 3: 'y', 4: 'z'},
'Symbol': {0: 'd', 1: 'b',
2: 'a', 3: 'e', 4: 'c'}}
json = pd.DataFrame(json_dict)
# Simulating your excel dataframe
excel_dict = {
'Symbol': {0: 'a', 1: 'b',
2: 'c'}}
excel = pd.DataFrame(excel_dict)
# Merge the dataframes
excel = pd.merge(
excel,
json,
on=["Symbol"],
how="left"
)
Output:
Symbol Token
0 a x
1 b v
2 c z