2
我有一个系列组成的正数或南。但是,当我计算的产品,我得到0为什么我为Series.prod()获得0?
样本输出:
In [14]: pricerelatives.mean()
Out[14]: 0.99110019490541013
In [15]: pricerelatives.prod()
Out[15]: 0.0
In [16]: len(pricerelatives)
Out[16]: 362698
In [17]: (pricerelatives>0).sum()
Out[17]: 223522
In [18]: (pricerelatives.isnull()).sum()
Out[18]: 139176
In [19]: 223522+139176
Out[19]: 362698
为什么我的pricerelatives.prod()
得到0?
更新: 感谢您的快速响应。不幸的是,它没有工作:
In [32]: import operator
In [33]: from functools import reduce
In [34]: lst = list(pricerelatives.fillna(1))
In [35]: the_prod = reduce(operator.mul, lst)
In [36]: the_prod
Out[36]: 0.0
明确摆脱空的也失败:
In [37]: pricerelatives[pricerelatives.notnull()].prod()
Out[37]: 0.0
更新2: 事实上,这正是我只是做了,并要增加。
In [39]: pricerelatives.describe()
Out[39]:
count 223522.000000
mean 0.991100
std 0.088478
min 0.116398
25% 1.000000
50% 1.000000
75% 1.000000
max 11.062591
dtype: float64
更新3:仍然对我来说很陌生。因此,更详细的信息:
In [46]: pricerelatives[pricerelatives<1].describe()
Out[46]:
count 50160.000000
mean 0.922993
std 0.083865
min 0.116398
25% 0.894997
50% 0.951488
75% 0.982058
max 1.000000
dtype: float64
更新4:比例是对周围的例子的0和> 0,但我的号码约1更聚集比0,1均匀,均匀1,2之间截止。
In [52]: 50160./223522
Out[52]: 0.2244074408783028
In [53]: pricerelatives[pricerelatives>=1].describe()
Out[53]:
count 173362.000000
mean 1.010806
std 0.079548
min 1.000000
25% 1.000000
50% 1.000000
75% 1.000000
max 11.062591
dtype: float64
In [54]: pricerelatives[pricerelatives<1].prod()
Out[54]: 0.0
你能告诉'pricerelatives.describe( )'? –
你可以在更新3中显示'> = 1'而不是'> 1'吗? –
另外,计算值<1的乘积,并显示出来。这应该是一个非常小的数字。 –