0

I have two dataframe 'df1' and 'df2'

df1=   a       b
       1       such as
       2       who I'm

df2=   a       keyword
       1       such
       1       as
       2       who
       2       I'm

Based on this two dataframe I want to create following dataframe

result =   a           keyword
           such as     such
           such as     as
           who I'm     who
           who I'm     I'm
1
  • Can you provide the constructors for your two dataframes? Commented Feb 27, 2022 at 6:53

1 Answer 1

1

IIUC, just perform a replacement with map:

df2['a'] = df2['a'].map(df1.set_index('a')['b'])
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.