Skip to content

DataFrame division returns infinity for 0 / 0 #8445

Closed
@keszybz

Description

@keszybz

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])

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions