正の数または nan で構成されるシリーズがあります。しかし、積を計算すると 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
で 0 になるのはなぜpricerelatives.prod()
ですか?
更新: 迅速な対応ありがとうございます。残念ながら、うまくいきませんでした:
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
null を明示的に取り除くことも失敗します。
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 の間の例のカットオフのすぐ近くにありますが、私の数値は、均一な 0,1 および均一な 1,2 よりも 1 の周りにはるかに集中しています。
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