sum of 'float64' column type in pandas return float instead of numpy.float64
<p>I have a dataframe in pandas. I am taking sum of a column of a dataframe as:</p>

<pre><code>x = data['col1'].sum(axis=0)
print(type(x))
</code></pre>

<p>I have checked that <code>col1</code> column in <code>data</code> dataframe is of type <code>float64</code>. But the type of <code>x</code> is <code>&lt;class 'float'&gt;</code>. I was expecting the type of <code>x</code> to be <code>numpy.float64</code>.</p>

<p>What is it that I am missing here?</p>

<p>pandas version - '0.18.0', numpy version - '1.10.4', python version - 3.5.2</p>

<p>This seems to be from the way that pandas is handling nans. When I set <code>skipna=False</code> in the <code>sum</code> method I get the <code>numpy</code> datatype</p>

<pre><code>import pandas as pd
import numpy as np

type(pd.DataFrame({'col1':[.1,.2,.3,.4]}).col1.sum(skipna=True))
#float

type(pd.DataFrame({'col1':[.1,.2,.3,.4]}).col1.sum(skipna=False))
#numpy.float64
</code></pre>

<p>The <code>sum</code> method is calling <code>nansum</code> from <code>pandas/core/nanops.py</code>, which produces the same behaviours. </p>

<pre><code>from pandas.core.nanops import nansum

type(sum(np.arange(10.0)))
# numpy.float64

type(nansum(np.arange(10.0)))
# float
</code></pre>

<p>Why <code>nansum</code> is converting from <code>numpy.float64</code> to <code>float</code>, I couldn't tell you. I've looked at the <code>nansum</code> source code, but none of the functions it itself calls seem to be producing that change.</p>

python pandas numpy