I have two dataframes, one with 300 names and one with 2000. I want to check if all of the words in each of the 300 names are contained in the 2000 in any iteration. For example:
Name 1: Mark, Alex, Smith,
Name 2: Mark, Joseph, Smith, Alex, the, first
Dataframe 1
Name 1 |
---|
'Mark', 'Alex', 'Smith' |
Dataframe 2
Name 2 |
---|
'Mark', 'Joseph', 'Alex', 'Smith', 'the', First' |
As you can see, the column in dataframe 2 contains all of the words from column in dataframe 1, but additional words in the name too.
My query should match here, because Name 2 contains all of the words from name 1 even though it is not an exact match. Each of the names is split into individual words in each cell.
Ideally, I would run a function across dataframe 2 which contains 2,000 names and see if any of those names have contain all of the words from dataframe 1.
Edit: Someone kindly pointed out in the comments that what I am trying to say, is can I find if Name 1 is a subset of Name 2.