Reputation: 43
have a df with values :
name number addition
tom 123 this is tom , number is [[number]]
mark 1234 this is mark , number is [[number]]
using regex how to map value in number column with [[number]] in addition column like this
name number addition
tom 123 this is tom , number is 123
mark 1234 this is mark , number is 1234
Upvotes: 1
Views: 225
Reputation: 93141
You can use apply
:
df['addition'] = df.apply(lambda row: row['addition'].replace('[[number]]', str(row['number'])), axis=1)
Upvotes: 3