Skip to content

TST: Add ExtensionArray base tests for ops between pandas objects and EAs #22974

Open
@TomAugspurger

Description

@TomAugspurger

We should document the expected behavior for binary operations between ExtensionArrays and pandas' own objects (Series, DataFrame, Index). We should update our own EAs to match the docs.

In [4]: integer_array([1, 2]) + pd.Series([1, 2])
Out[4]: IntegerArray([2, 4], dtype='Int64')

Out[4] should be a Series with "Int64" dtype, to match the behavior of ndarray + series.

We've documented this, but need to test between series, index, dataframe, and the array class

def test_arith_series_with_array(self, data, all_arithmetic_operators):
# ndarray & other series
op_name = all_arithmetic_operators
s = pd.Series(data)
self.check_opname(s, op_name, pd.Series([s.iloc[0]] * len(s)),
exc=self.series_array_exc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsExtensionArrayExtending 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