Dataframe returning None value
<p>I was returning a dataframe of characters from GOT such that they were alive and predicted to die, but only if they have some house name. (important person). I was expecting it to skip NaN's, but it returned them as well. I've attached screenshot of output. Please help.</p>

<p>PS I haven't attached any spoilers so you may go ahead.</p>

<pre><code>import pandas
df=pandas.read_csv('character-predictions.csv')
a=df[((df['actual']==1) &amp; (df['pred']==0)) &amp; (df['house'] !=None)]
b=a[['name', 'house']]
</code></pre>

<p><a href="http://i.stack.imgur.com/xhUEb.png" rel="nofollow"><img src="http://i.stack.imgur.com/xhUEb.png" alt="enter image description here"></a></p>

<p>You need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.notnull.html" rel="nofollow"><code>notnull</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollow"><code>ix</code></a> for selecting columns:</p>

<pre><code>b = df.ix[((df['actual']==1) &amp; (df['pred']==0)) &amp; (df['house'].notnull()), ['name', 'house']]
</code></pre>

<p>Sample:</p>

<pre><code>df = pd.DataFrame({'house':[None,'a','b'],
                   'pred':[0,0,5],
                   'actual':[1,1,5],
                   'name':['J','B','C']})

print (df)
   actual house name  pred
0       1  None    J     0
1       1     a    B     0
2       5     b    C     5

b = df.ix[((df['actual']==1) &amp; (df['pred']==0)) &amp; (df['house'].notnull()), ['name', 'house']]
print (b)
  name house
1    B     a
</code></pre>

<p>You can also check <a href="http://pandas.pydata.org/pandas-docs/stable/missing_data.html#values-considered-missing" rel="nofollow">pandas documentation</a>:</p>

<p><strong>Warning</strong></p>

<blockquote>
  <p>One has to be mindful that in python (and numpy), the nan's donât compare equal, but None's do. Note that Pandas/numpy uses the fact that np.nan != np.nan, and treats None like np.nan.</p>
</blockquote>

<pre><code>In [11]: None == None
Out[11]: True

In [12]: np.nan == np.nan
Out[12]: False
</code></pre>

<blockquote>
  <p>So as compared to above, a scalar equality comparison versus a None/np.nan doesnât provide useful information.</p>
</blockquote>

<pre><code>In [13]: df2['one'] == np.nan
Out[13]: 
a    False
b    False
c    False
d    False
e    False
f    False
g    False
h    False
Name: one, dtype: bool
</code></pre>

python pandas indexing multiple-columns