Skip to content

Default ExtensionScalarOpsMixin for divmod is incorrect #22930

Closed
@TomAugspurger

Description

@TomAugspurger

Code Sample, a copy-pastable example if possible

In [1]: from pandas.tests.extension.decimal.array import *

In [2]: arr = DecimalArray([decimal.Decimal(1), decimal.Decimal(2), decimal.Decimal(3)])

In [3]: divmod(arr, 2)
Out[3]:
[(Decimal('0'), Decimal('1')),
 (Decimal('1'), Decimal('0')),
 (Decimal('1'), Decimal('1'))]

Expected Output

In [11]: a, b = zip(*(divmod(x, 2) for x in arr))

In [12]: DecimalArray(a), DecimalArray(b)
Out[12]:
(DecimalArray(array([Decimal('0'), Decimal('1'), Decimal('1')], dtype=object)),
 DecimalArray(array([Decimal('1'), Decimal('0'), Decimal('1')], dtype=object)))

Any others?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions