Pandas Series any() vs all()
<pre><code>&gt;&gt;&gt; s = pd.Series([float('nan')])
&gt;&gt;&gt; s.any()
False
&gt;&gt;&gt; s.all()
True
</code></pre>

<p>Isn't that weird? Documentation on <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.any.html" rel="nofollow">any</a> (Return whether any element is True over requested axis) and <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.all.html" rel="nofollow">all</a> (Return whether all elements are True over requested axis) is similar, but the difference in behavior doesn't seem to make sense to me.</p>

<p>What gives?</p>

<p>It seems to be an issue with how <code>pandas</code> normally ignores <code>NaN</code> unless told not to:</p>

<pre><code>&gt;&gt;&gt; pd.Series([float('nan')]).any()
False
&gt;&gt;&gt; pd.Series([float('nan')]).all()
True
&gt;&gt;&gt; pd.Series([float('nan')]).any(skipna=False)
True
&gt;&gt;&gt; 
</code></pre>

<p>Note, <code>NaN</code> is falsey:</p>

<pre><code>&gt;&gt;&gt; bool(float('nan'))
True
</code></pre>

<p>Also note: this is consistent with the built-in <code>any</code> and <code>all</code>. Empty iterables return <code>True</code> for <code>all</code> and <code>False</code> for <code>any</code>. <a href="http://stackoverflow.com/questions/3275058/reason-for-all-and-any-result-on-empty-lists">Here is a relevant question on that topic.</a></p>

<p>Interestingly, the default behavior appears to be inconsistent with the documentation:</p>

<blockquote>
  <p>skipna : boolean, default True
          Exclude NA/null values. If an entire row/column is NA, the result
          will be NA</p>
</blockquote>

<p>But observe:</p>

<pre><code>&gt;&gt;&gt; pd.Series([float('nan')]).any(skipna=None)
False
&gt;&gt;&gt; pd.Series([float('nan')]).any(skipna=True)
False
&gt;&gt;&gt; pd.Series([float('nan')]).any(skipna=False)
True
&gt;&gt;&gt; 
</code></pre>

python pandas series