Skip to content
Advertisement

Python/Pandas bring value based on another DF

I have two dataframe, below

JavaScript

I am trying to fill df[“Possibilites”] with df2[“first_name”] if key_words in df2[“first_name”] with this code:

JavaScript

it returns what i expect but gives a warning also:

” SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame”

What should I do instead using “for loop”? more practical or right way…

Advertisement

Answer

Use custom lambda function with generator with join for match multiple matched values, if necessary convert values to lowercase:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement