Convert string based NaN's to numpy NaN's
<p>I have a dataframe with a part of it shown as below:</p>

<pre><code>2016-12-27              NaN
2016-12-28              NaN
2016-12-29              NaN
2016-12-30              NaN
2016-12-31              NaN
Name: var_name, dtype: object
</code></pre>

<p>The column contains NaN as strings/objects. How can I convert it to a numpy nan instead. Best would be able to do so when I read in the csv file.</p>

<p>Suppose we have:</p>

<pre><code>&gt;&gt;&gt; df=pd.DataFrame({'col':['NaN']*10})
</code></pre>

<p>You can use <code>.apply</code> to convert:</p>

<pre><code>&gt;&gt;&gt; new_df=df.apply(float, axis=1)
&gt;&gt;&gt; type(new_df[0])
&lt;type 'numpy.float64'&gt;
</code></pre>

python pandas numpy