王礼平 2020-03-31 07:40
浏览 107

如何把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)

df_covid19['continent']=df_covid19.Country_Region.map(lambda x: country_to_continent(x))

错误提示:TypeError: argument of type 'functools._lru_cache_wrapper' is not iterable
谁能帮我看看什么原因?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 matlab计算中误差
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制
    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊