8000 Handling underlying exceptions in ExtensionArrayOpsMixin · Issue #22944 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content
Handling underlying exceptions in ExtensionArrayOpsMixin #22944
Closed
@TomAugspurger

Description

@TomAugspurger

I'm growing to dislike the try / except to wrap the results of a binop. That's what hid #22930.

I wonder, is it possible for EA authors to annotate which ops form an algebra for their Extension type, so that we can know ahead of time whether the result should be wrappe? Something like

_ops_return_ea = {
    '__add__', '__sub__', ...
}

and if the op name is in those, then we attempt to wrap the result, but don't catch any errors? If the op name isn't in those then we return an ndarray?

The thing that would ruin this is if there were legitimate cases where whether or not the result can be wrapped depends on the value, rather than the type. Can we think of any of those?

cc @Dr-Irv

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsExtensionArrayExtending pandas with custom dtypes or arrays.Numeric 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

      0