0

I have a data about diabetes patients. I want to fill nan values in "medical speciality" column based on the numbers of three column features " outpatients, inpatients and emergency numbers they already have".

but this ValueError displayed :

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

I think my code has a problem in datatypes can anyone help me to fix this please?

thank you .

this is my code ::

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

for i in 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)
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • Is `[1, 2, 3]` greater than or less than `[1, 3, 2]`? That's what the issue is; you're comparing arrays of values and asking if the whole array is greater than or less than another – roganjosh Nov 09 '19 at 18:20
  • 1
    Possible duplicate of [Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()](https://stackoverflow.com/questions/36921951/truth-value-of-a-series-is-ambiguous-use-a-empty-a-bool-a-item-a-any-o) – Trenton McKinney Nov 09 '19 at 18:22
  • Thanks for replay. now I understand the problem "It is bcz I am comparing 3 series types". But I am still working to solve this problem – Arwa Al-Ghamdi Nov 10 '19 at 07:37

0 Answers0