DataFrame division returns infinity for 0 / 0 · Issue #8445 · pandas-dev/pandas (original) (raw)

xref #9286

0 / 0 does not have a value, and should return NaN, not infinity.

x = pd.DataFrame([[0, 0], [1, 0], [-1, 0]]) x[0] / x[1] 0 inf <------------- here 1 inf 2 -inf dtype: float64

numpy does this correctly:

y = np.array([[0, 0], [1, 0], [-1, 0]]) y[:, 0] / y[:, 1] array([ nan, inf, -inf])