pandas.value_counts for NA
<p><a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.value_counts.html" rel="nofollow"><code>pandas.value_counts</code></a>
works for numeric arrays with <code>None</code>:</p>

<pre><code>&gt; s = pd.Series([1,2,1,None])
&gt; vc = s.value_counts(dropna=False)
&gt; vc
 1.0    2
 2.0    1
NaN     1
dtype: int64
&gt; vc.index
Float64Index([1.0, 2.0, nan], dtype='float64')
&gt; vc[1], vc[float('NaN')]
2 1
</code></pre>

<p>but not for strings:</p>

<pre><code>&gt; s = pd.Series(['1','2','1',None])
&gt; vc = s.value_counts(dropna=False)
&gt; vc
1      2
2      1
NaN    1
dtype: int64
&gt; vc.index
Index([u'1', u'2', nan], dtype='object')
&gt; [type(o) for o in vc.index]
[&lt;type 'str'&gt;, &lt;type 'str'&gt;, &lt;type 'float'&gt;]
</code></pre>

<p>How come there is a <code>float</code> here?!</p>

<pre><code>&gt; vc['1']
2
&gt; vc[float('NaN')]
TypeError: cannot do label indexing on &lt;class 'pandas.indexes.base.Index'&gt; with these indexers [nan] of &lt;type 'float'&gt;
</code></pre>

<p>How do I access counts for the <code>None</code> in <code>s</code>?</p>

<p>I was also surprised to see that <code>cv[np.nan]</code> does not work, but this does: <code>vc.loc[np.nan]</code></p>

python pandas types