how do I drop NA within pandas.DataFrame.query

pandas, python

Solution

Idea #2: what's distinctive about NaNs is that they're not equal to themselves:

In [22]: df.query("A == A")
Out[22]: 
     A
0 -1.0
1  0.0
2  1.0
4  2.0
6  3.0
7  4.0

(The original idea #1 was to use `df.query("A.notnull()")`, but that only worked because `numexpr` wasn't installed in that environment, which limits the usefulness of `query` in the first place.)

Problem

consider the `df` ``` df = pd.DataFrame(dict(A=[-1, 0, 1, np.nan, 2, np.nan, 3, 4])) ``` I can drop NA like this ``` df.dropna() ``` but how do I do it within the `query` method ``` df.query('A is not null') ``` doesn't work... what does?

Original source