Skip to content Skip to sidebar Skip to footer

Querying A Single-row Dataframe With And'ed Conditionals

Using pandas 0.13, I have a single-row DataFrame: In [23]: is_same Out[23]: bid bidsize ask asksize 168 False False False False [1 rows x 4 columns] I can query t

Solution 1:

might be a bug; boolean handling like this I don't think has been completely tested (the evaluating to booleans of course is, e.g. 'values>0'); you already have the result

You can do this

In [5]: df.query('bid==False and ask==False')
Out[5]: 
       bid bidsize    ask asksize
168FalseFalseFalseFalse

[1rows x 4 columns]

In [6]: df.query('bid==False and ask==True')
Out[6]: 
Empty DataFrame
Columns: [bid, bidsize, ask, asksize]
Index: []

[0rows x 4 columns]

Post a Comment for "Querying A Single-row Dataframe With And'ed Conditionals"