如何解决ValueError:系列的真值不明确。使用a.empty,a.bool(),a.item(),a.any()或a.all()

我有一个有关糖尿病患者的数据。我想根据“门诊病人,住院病人和他们已经拥有的急诊电话号码”这三栏特征的数量在“医学专长”栏中填写nan值。

但是显示此ValueError:

  

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

我认为我的代码在数据类型方面存在问题,有人可以帮助我解决此问题吗?

谢谢。

这是我的代码::

''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''

对于我在df中:

    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)
sw706 回答:如何解决ValueError:系列的真值不明确。使用a.empty,a.bool(),a.item(),a.any()或a.all()

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3131785.html

大家都在问