I have a pandas dataframe and would like to replace words in column something if they are the same as column to_hide. So I'd like to go from here
to_hide something
0 bla there is bla over there
1 sth i cannot see anything
2 sth else sth else is beautiful
to here
to_hide something
0 bla there is to_hide over there
1 sth i cannot see anything
2 sth else to_hide is beautiful
The below unfortunately throws an error
df = pd.DataFrame({'to_hide':['bla','sth','sth else'], 'something':['there is bla over there','i cannot see anything','sth else is beautiful']})
df.assign(**{'something' : df['something'].str.replace(df['to_hide'], 'to_hide')})
TypeError: 'Series' objects are mutable, thus they cannot be hashed
how can I write it so it works?