<p dir="auto">I got two snippets code as follows.</p>
<blockquote>
<blockquote>
<p dir="auto">numpy.std([766897346, 766897346, 766897346, 766897346, 766897346, 766897346, 766897346, 766897346, 766897346, 766897346])</p>
<p dir="auto">0</p>
<p dir="auto">pd.Series([766897346, 766897346, 766897346, 766897346, 766897346, 766897346, 766897346, 766897346, 766897346, 766897346]).std(ddof=0)</p>
<p dir="auto">10.119288512538814</p>
</blockquote>
</blockquote>
<p dir="auto">The two lists are identical but the result are quite different. I think the pandas' result must be wrong. I work on the latest version 0.16.2 with Python 3.4.</p>
<p dir="auto">May I ask why? Is it a bug?</p>
<p dir="auto">The var method acts inconsistently when used on the Series vs the numpy array returned from values:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="dat = pd.DataFrame({'x': [1,2,3,4,0,0,0]})
print(dat['x'].values.var())
print(dat['x'].var())"><pre class="notranslate"><span class="pl-s1">dat</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'x'</span>: [<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">4</span>,<span class="pl-c1">0</span>,<span class="pl-c1">0</span>,<span class="pl-c1">0</span>]})
<span class="pl-en">print</span>(<span class="pl-s1">dat</span>[<span class="pl-s">'x'</span>].<span class="pl-s1">values</span>.<span class="pl-en">var</span>())
<span class="pl-en">print</span>(<span class="pl-s1">dat</span>[<span class="pl-s">'x'</span>].<span class="pl-en">var</span>())</pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Prints:
2.24489795918
2.61904761905"><pre class="notranslate"><code class="notranslate">Prints:
2.24489795918
2.61904761905
</code></pre></div>
<p dir="auto">This is due to numpy using ddof=0 as its default (calculates the biased variance), whereas pandas calculates the unbiased variance by default. These two should be consistent, so either pandas should adapt or numpy should (maybe it should be numpy since we should calculate unbiased by default?).</p>
<p dir="auto">The other problem is that pandas does not calculate the variance of this DataFrame properly.<br>
Inconsistent definition aside, the variance should clearly not be zero when calculated from pandas.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="dat = pd.DataFrame({'x': [9.0692124699,9.0692124692,9.0692124702,9.0692124686,
                          9.0692124687,9.0692124707,9.0692124679,9.0692124685,
                          9.0692124698,9.0692124719,9.0692124698,9.0692124692,
                          9.0692124689,9.0692124673,9.0692124707,9.0692124714,
                          9.0692124714,9.0692124734,9.0692124719,9.0692124710,
                          9.0692124694,9.0692124705,9.0692124713,9.0692124717
]})
print(dat['x'].values.var())
print(dat['x'].var())"><pre class="notranslate"><span class="pl-s1">dat</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'x'</span>: [<span class="pl-c1">9.0692124699</span>,<span class="pl-c1">9.0692124692</span>,<span class="pl-c1">9.0692124702</span>,<span class="pl-c1">9.0692124686</span>,
                          <span class="pl-c1">9.0692124687</span>,<span class="pl-c1">9.0692124707</span>,<span class="pl-c1">9.0692124679</span>,<span class="pl-c1">9.0692124685</span>,
                          <span class="pl-c1">9.0692124698</span>,<span class="pl-c1">9.0692124719</span>,<span class="pl-c1">9.0692124698</span>,<span class="pl-c1">9.0692124692</span>,
                          <span class="pl-c1">9.0692124689</span>,<span class="pl-c1">9.0692124673</span>,<span class="pl-c1">9.0692124707</span>,<span class="pl-c1">9.0692124714</span>,
                          <span class="pl-c1">9.0692124714</span>,<span class="pl-c1">9.0692124734</span>,<span class="pl-c1">9.0692124719</span>,<span class="pl-c1">9.0692124710</span>,
                          <span class="pl-c1">9.0692124694</span>,<span class="pl-c1">9.0692124705</span>,<span class="pl-c1">9.0692124713</span>,<span class="pl-c1">9.0692124717</span>
]})
<span class="pl-en">print</span>(<span class="pl-s1">dat</span>[<span class="pl-s">'x'</span>].<span class="pl-s1">values</span>.<span class="pl-en">var</span>())
<span class="pl-en">print</span>(<span class="pl-s1">dat</span>[<span class="pl-s">'x'</span>].<span class="pl-en">var</span>())</pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Prints:
2.06817742558e-18
0.0"><pre class="notranslate"><code class="notranslate">Prints:
2.06817742558e-18
0.0
</code></pre></div>
<p dir="auto">Here is the system information:<br>
INSTALLED VERSIONS:<br>
commit: None<br>
python: 3.4.0.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 3.13.0-52-generic<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_CA.UTF-8</p>
<p dir="auto">pandas: 0.16.1<br>
numpy: 1.9.2</p>