這個問題在這里已經有了答案: inf 和 nan 是什么? (5 個回答) 昨天關閉。
我試圖在資料框中找到特定列的平均值,但我采用 -inf 作為結果,這是什么意思?
df [df["col_name1"] == 0]["col_name1"].mean()
result : -inf
uj5u.com熱心網友回復:
它是“負無窮大”,這是 IEEE 754 定向舍入的結果
- https://en.wikipedia.org/wiki/IEEE_754#Directed_roundings
- https://numpy.org/devdocs/reference/constants.html
有貨 Python
>>> -math.inf
-inf
在 Pandas/NumPy 中
>>> import numpy as np
>>> np.Inf
inf
有向舍入示例
>>> a = 1 * math.inf
>>> a 100
inf
>>> -a 100
-inf
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/312860.html
上一篇:給定總量,如何將比率轉換為數字?
