Based on the following post: Python - Pandas - Replace a string from a column based on the value from other column
I was doing some similar on my side and I have faced new challenges. I use the same example as the previous post.
The new challenge that consists with the substrings.
Imagine that I have the following dataframe:
What I am trying is to replace on col2 the values that exists on col0 with the values from col2.
If I use the code (it is the same from the previous post):
df['col3'] = df['col1'].replace(df['col0'].values, df['col2'].values, regex = True)
I will return the following dataframe:
And what I am trying is the following one:
Can I add some more precision on .values to achieve this?
Thanks!


