I have two pandas DataFrames in python. DF A contains a column, which is basically sentence-length strings.
|---------------------|------------------|
| sentenceCol | other column |
|---------------------|------------------|
|'this is from france'| 15 |
|---------------------|------------------|
DF B contains a column that is a list of countries
|---------------------|------------------|
| country | other column |
|---------------------|------------------|
|'france' | 33 |
|---------------------|------------------|
|'spain' | 34 |
|---------------------|------------------|
How can I loop through DF A and assign which country the string contains? Here's what I imagine DF A would look like after assignment...
|---------------------|------------------|-----------|
| sentenceCol | other column | country |
|---------------------|------------------|-----------|
|'this is from france'| 15 | 'france' |
|---------------------|------------------|-----------|
One additional complication is that there can be more than one country per sentence, so ideally this could assign every applicable country to that sentence.
|-------------------------------|------------------|-----------|
| sentenceCol | other column | country |
|-------------------------------|------------------|-----------|
|'this is from france and spain'| 16 | 'france' |
|-------------------------------|------------------|-----------|
|'this is from france and spain'| 16 | 'spain' |
|-------------------------------|------------------|-----------|