Q: Change substring in a column from a dict (Python Pandas) I've got 2 dataframe from 2 excel sheets (in the same file). I want to change the name of each molecules in the first sheet 1 with the "official id" from a database present in the second sheet 2.
screen first dataframe
screen second dataframe
import pandas as pd
reactions = pd.read_excel ("/Users/Python/reactions.xlsx")

molecules = pd.read_excel ("/Users/Python/reactions.xlsx" , 
                          sheet_name= 'METS')

d = molecules.set_index('MOLID')['MOLNAME'].to_dict()
#not work 
reactions['EQUATION'] = reactions['EQUATION'].str.replace('\d+','').replace(d)

I have the old/new molecules name in a dictionary, that I also created from the 2nd sheet:
d
And it is like 
{....'glucose[c]': 'glc_D',
 'glucose[s]': 'glc_D',
 'glucose[x]': 'glc_D', ....}
In the first database the column where I want to change the molecules name is call EQUATION and it is like: "ATP[c] + glucose[c] => ADP[c] + glucose6phosphate[c]"
I try change with this code, it doesn't error, but the molecules in my dataframe haven't changed.
Thank you for the time

A: How to replace multiple substrings in a Pandas series using a dictionary? 
I think if you adjust the code to something like this you are able to do it
 reactions['EQUATION'].apply(lambda x: ' '.join([d.get(i, i) for i in x.split()]))

