Skip to content

Index division by zero not filled #19322

Closed
@jbrockmendel

Description

@jbrockmendel

idx = pd.Index(range(5))
>>> idx
Int64Index([0, 1, 2, 3, 4], dtype='int64')

>>> idx / 0
Int64Index([0, 0, 0, 0, 0], dtype='int64')

>>> idx // 0
Int64Index([0, 0, 0, 0, 0], dtype='int64')

>>> idx % 0
Int64Index([0, 0, 0, 0, 0], dtype='int64')

>>> divmod(idx, 0)
(Int64Index([0, 0, 0, 0, 0], dtype='int64'), Int64Index([0, 0, 0, 0, 0], dtype='int64'))

>>> idx.astype('uint64') / 0
UInt64Index([0, 0, 0, 0, 0], dtype='uint64')

Others are OK:

>>> idx.__truediv__(0)
Float64Index([nan, inf, inf, inf, inf], dtype='float64')

>>> idx.astype('float64') / 0
Float64Index([nan, inf, inf, inf, inf], dtype='float64')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsDtype ConversionsUnexpected or buggy dtype conversionsNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions