jeudi 2 août 2018

If condition python

All, I have a dataframe that looks like this.

    PctPerBroker  MaxPctBalance  MinPctBalance
29      0.222204            0.3            0.1
30      0.172765            0.3            0.1
31      0.166435            0.3            0.1
32      0.211877            0.3            0.1
33      0.226718            0.3            0.1

I am struggling with some basic stuff:

if ( (Broker['PctPerBroker']>Broker['MaxPctBalance'])| Broker['PctPerBroker']<Broker['MinPctBalance']) ): 

   do something

i get an error

    if ( (Broker['PctPerBroker']>Broker['MaxPctBalance']) ):# | (Broker['PctPerBroker']<Broker['MinPctBalance']) ):
  File "/apps/qtrinst/install/python/anaconda/envs/sx_anaconda/lib/python3.5/site-packages/pandas/core/generic.py", line 1121, in __nonzero__
    .format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

where am I going wrong? Thanks a lot

Aucun commentaire:

Enregistrer un commentaire