I've a data frame column containing "text with country names" I need to extract country names like list of values and store it in a new column.
import pycountry
country_extract = []
text = "Mexico|Mexico or Guatemala Tunesia Coastal Ecuador at xyz,
Jordan Amman (?) |United States|United States|Canada |Egypt, from xyz
of abcd, Cairo "
for country in pycountry.countries:
if country.name in text:
df_metobjects['country_extract'] = (country.name)
print(country.name)
Output - Canada Ecuador Egypt Guatemala Jordan Mexico United States
I need to process on a column and store the extracted data as a list in a new column
Comments
Post a Comment