ValueError:只能比较具有相同标签的数据帧对象

2024-10-03 15:34:16 发布

您现在位置:Python中文网/ 问答频道 /正文

教育程度是我的数据框架的名称。这里有什么问题?每当我尝试使用以下函数时,它都会给出 ValueError: Can only compare identically-labeled DataFrame objects 并且说这个问题与if 2*受过教育的女性一致<;受过教育的男人。 有人能帮忙吗

def gender_inequality(country):
    educated_female = educational_attainment[(educational_attainment['country_name']==country)&(educational_attainment['series_name']=="UIS: Percentage of population age 25+ with at least a completed bachelor's or equivalent degree (ISCED 6 or higher). Female")] 
    educated_male = educational_attainment[(educational_attainment['country_name']==country)&(educational_attainment['series_name']=="UIS: Percentage of population age 25+ with at least a completed bachelor's or equivalent degree (ISCED 6 or higher). Male")]
    if 2*educated_female < educated_male:        
         countries_with_inequality.append(country)```

Tags: orofnameifwithcountryfemaleseries