0

I asked this question on pandas dataframe-python check if string exists in another column ignoring upper/lower case but i have a new update

I have a new row in a new dataframe :

Id    CompanyName                                           EDescription

4    finance company - finance service sol         Project manager at finance company
5    finance company - finance service sol         IT

i want my output to return rows that contain any string from CompanyName that is in EDescription. Even if it's not exactly the same. if i use df[df.apply(lambda x: x['Name'] in x['Description'], axis = 1)] with all upper/lower case condition, i still get an empty dataframe.

i want my final output to be :

Id    CompanyName                                           EDescription
    
4    finance company - finance service sol         Project manager at finance company
1
  • Please, could you be more specific? What do you mean by any string? You meant by all strings in CompanyName: [finance, company, finance, service, sol ]... or you meant by all the substrings separated by ' - ': [finance company , finance service sol] Commented Aug 12, 2020 at 7:15

1 Answer 1

0

try this,

mask = (
    df.apply(lambda x :
             x['CompanyName'].split("-")[0].strip().lower() in x['EDescription'].lower(), axis=1)
)

df[mask]

   Id  ...                        EDescription
0   4  ...  Project manager at finance company
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.