Pandas, return df for which values of a certain column is null
<p>Im working from SQL code moving it to python, i have a <code>WHERE</code> condition saying where points Is <code>NULL</code></p>

<p>I need to print my dataframe, data,  such that the one column in question, points, contains all Null's</p>

<p>eg.</p>

<pre><code>name:    age:    points:
Sean     12      3
Jack     14      0
Peter    11      2
David    16      0
Paul     15      0
</code></pre>

<p>and i want it to return this:</p>

<pre><code>name:    age:
Jack     14
David    16
Paul     15
</code></pre>

<p>any help appreciated</p>

<p>Use <code>boolean indexing</code> if need filter where is value <code>0</code>:</p>

<pre><code>df = pd.DataFrame({'points': {0: 3, 1: 0, 2: 2, 3: 0, 4: 0}, 
                   'name': {0: 'Sean', 1: 'Jack', 2: 'Peter', 3: 'David', 4: 'Paul'},
                   'age': {0: 12, 1: 14, 2: 11, 3: 16, 4: 15}})    
print (df)
   age   name  points
0   12   Sean       3
1   14   Jack       0
2   11  Peter       2
3   16  David       0
4   15   Paul       0

df1 = df.ix[df.points == 0,['name','age']]
print (df1)
    name  age
1   Jack   14
3  David   16
4   Paul   15
</code></pre>

<p>And if values are <code>NaN</code>:</p>

<pre><code>df = pd.DataFrame({'points': {0: 3, 1: np.nan, 2: 2, 3: np.nan, 4: np.nan}, 
                   'name': {0: 'Sean', 1: 'Jack', 2: 'Peter', 3: 'David', 4: 'Paul'},
                   'age': {0: 12, 1: 14, 2: 11, 3: 16, 4: 15}})    
print (df)
   age   name  points
0   12   Sean     3.0
1   14   Jack     NaN
2   11  Peter     2.0
3   16  David     NaN
4   15   Paul     NaN

df1 = df.ix[df.points.isnull(),['name','age']]
print (df1)
    name  age
1   Jack   14
3  David   16
4   Paul   15
</code></pre>

python sql pandas dataframe