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>Yes, you can do this when reading the csv file.</p>

<pre><code>df = pd.read_csv('test.csv', names=['t', 'v'], dtype={'v':np.float64})
</code></pre>

<p>Check the docs of <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow">pandas.read_csv</a>. There are some parameters is useful for your application:</p>

<ul>
<li>names </li>
<li>dtype</li>
<li>na_values</li>
</ul>

<p>Hope this would be helpful.</p>

python pandas numpy