如何修正ValueError:级数的真值是模糊的。使用a.empty、a.bool()、a.item()、a.any()或a.all()

2024-05-19 00:23:18 发布

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

我有糖尿病病人的资料。我想在“医学专业”一栏中,根据“门诊、住院和急诊”三个一栏特征的数字填写nan值

但是这个值错误显示:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

我想我的代码在数据类型上有问题,有人能帮我解决这个问题吗

谢谢你

这是我的密码:

好了,好了,好了

对于df中的i:

    a = df['number_outpatient']
    b = df['number_inpatient']
    c = df['number_emergency']
    d = df['medical_specialty']

    if a > b > c:
        d.fillna("Outpatient Clinic", inplace = True)
    elif a > c > b:
        d.fillna("Outpatient Clinic", inplace = True)
    elif b > a > c:
        d.fillna("Inpatient", inplace = True)
    elif b > c > a:
        d.fillna("Inpatient", inplace = True)
    elif c > b > a:
        d.fillna("Emergency", inplace = True)
    elif c > a > b:
        d.fillna("Emergency", inplace = True)
    else:
        d.fillna("Overloded / No Bed", inplace = True)

Tags: truenumberdfclinicelif资料病人住院

热门问题