Assume import jmespath
. Let's say I have some data like:
In [3]: data=[{'foo':10}, {'foo':float('nan')}, {'foo':32}]
In [4]: data
Out[4]: [{'foo': 10}, {'foo': nan}, {'foo': 32}]
I want to use jmespath to count the number of nodes that are nan. I can't seem to get it to. I can count the non-nan nodes like so:
jmespath.search('length([?@.foo.abs(@) >= `0`])',data)
I have tried comparing to nan
and NaN
but that doesn't work, and frankly it shouldn't because nan doesn't equal nan. However, there is no is_nan() function that I can see. I suppose I could convert to string and then compare them? That seems like a last resort. Is there some is_nan I don't see documented?