我想把dataframe中的列Country_Region,内容是国家名字,转化为相应的大洲的名称
import pycountry_convert as pc
def country_to_continent(country_name):
country_alpha2=pc.country_name_to_country_alpha2(country_name)
country_continent_code=pc.country_alpha2_to_continent_code(country_alpha2)
country_continent_nam=pc.convert_continent_code_to_continent_name(country_continent_code)
return country_continent_name
df['continent']=df.Country_Region.map(lambda x: country_to_continent(x))
运行报错:TypeError: argument of type 'functools._lru_cache_wrapper' is not iterable