首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >std() Pandas发行

std() Pandas发行
EN

Stack Overflow用户
提问于 2018-03-22 04:14:19
回答 3查看 836关注 0票数 4

,这会是个bug吗?当我对groupby对象使用describe()或std()时,我得到了不同的答案--

代码语言:javascript
运行
复制
import pandas as pd
import numpy as np
import random as rnd

df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
     ...:                           'foo', 'bar', 'foo', 'foo'],
     ...:                    'B' : ['one', 'one', 'two', 'three',
     ...:                           'two', 'two', 'one', 'three'],
     ...:                    'C' : 1*(np.random.randn(8)>0.5),
     ...:                    'D' : np.random.randn(8)})
df.head()

df[['C','D']].groupby(['C'],as_index=False).describe()
# this line gives me the standard deviation of 'C' to be 0,0. Within each    group value of C is constant, so that makes sense. 

df[['C','D']].groupby(['C'],as_index=False).std()
# This line gives me the standard deviation of 'C' to be 0,1. I think this is wrong
EN

Stack Overflow用户

发布于 2018-04-12 18:07:38

我的朋友mukherjees和我用这个做了更多的试验,并认为std()确实有问题。您可以在下面的链接中看到"std()与.apply(np.std,ddof=1)“的显示方式。在注意到之后,我们还发现了以下相关的bug报告:

https://github.com/pandas-dev/pandas/issues/10355

票数 1
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49420444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档