Python if function

Asked

Viewed 21 times

-1

Hello, In a database with vaccine information per day, I want to compare whether the sum of each laboratory (Sinovac, Pfizer and Astrazeneca) is different from the reported total. If it is, I want you to print out the date.

I’m using the following code:

Fecha=data[["Fecha"]]

for i in Fecha:
    primera = (data["1era Dosis Sinovac"] + data["1era Dosis Pfizer"] + data["1era Dosis Astrazeneca"])
    print(primera)
    if primera != data["Total Dosis 1"]:
        print(i)

And the mistake you make is:


  File "<ipython-input-38-f2dd61100bee>", line 4, in <module>
    if primera > data["Total Dosis 1"]:

  File "C:\Users\andre\anaconda3\lib\site-packages\pandas\core\generic.py", line 1442, in __nonzero__
    raise ValueError(

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

I appreciate your help!

  • Could you update the post with an example of your dataframe? You don’t need to have real data. But before anything try to change Fecha=data[["Fecha"]] for Fecha=data["Fecha"]

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.