For a df I'd like to handle nan's with the query functionality. df.query('~A.isnull() & ...') doesn't work because eval doesn't support function calls ("NotImplementedError: 'Call' nodes are not implemented"), and df('A != @nan') fails in the way you'd expect it to with nan comparison (that is, not filtering anything). Should we (or do we already) have a way to filter nulls with query()?
Also, I can open a separate issue if it deserves one, but this related error message seemed a bit funny
df.query('A != @np.nan') # => NotImplementedError: N-dimensional objects, where N > 2, are not supported with eval
The standard trick to identify NaN is to use the fact that NaN is the only number x such that x != x. So something like df.query('A != A & ...') should work.
Ah very cool! Looks like that'll be sufficient, thanks.
Most helpful comment
The standard trick to identify NaN is to use the fact that NaN is the only number
xsuch thatx != x. So something likedf.query('A != A & ...')should work.