1

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

1 Answer 1

3

You can use apply:

df['addition'] =  df.apply(lambda row: row['addition'].replace('[[number]]', str(row['number'])), axis=1)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.