Skip to content

BUG: op(frame, series) raising NotImplementedError with extension dtypes #34311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jorisvandenbossche opened this issue May 22, 2020 · 3 comments
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Numeric Operations Arithmetic, Comparison, and Logical operations Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@jorisvandenbossche
Copy link
Member

In [1]: df = pd.DataFrame(np.random.randint(0, 100, (10, 3)), dtype="Int64", columns=['a', 'b', 'c']) 

In [2]: s = pd.Series([1, 2, 3], dtype="int64", index=["a", "b", "c"])

In [3]: df + s 
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-3-c26e56e5136b> in <module>
----> 1 df + s

~/scipy/pandas/pandas/core/ops/__init__.py in f(self, other, axis, level, fill_value)
    715             axis = self._get_axis_number(axis) if axis is not None else 1
    716             new_data = _combine_series_frame(
--> 717                 self, other, pass_op, axis=axis, str_rep=str_rep
    718             )
    719         else:

~/scipy/pandas/pandas/core/ops/__init__.py in _combine_series_frame(left, right, func, axis, str_rep)
    516 
    517         array_op = get_array_op(func, str_rep=str_rep)
--> 518         bm = left._mgr.apply(array_op, right=rvalues.T, align_keys=["right"])
    519         return type(left)(bm)
    520 

~/scipy/pandas/pandas/core/internals/managers.py in apply(self, f, align_keys, **kwargs)
    393 
    394             if callable(f):
--> 395                 applied = b.apply(f, **kwargs)
    396             else:
    397                 applied = getattr(b, f)(**kwargs)

~/scipy/pandas/pandas/core/internals/blocks.py in apply(self, func, **kwargs)
    334         """
    335         with np.errstate(all="ignore"):
--> 336             result = func(self.values, **kwargs)
    337 
    338         return self._split_op_result(result)

~/scipy/pandas/pandas/core/ops/array_ops.py in arithmetic_op(left, right, op, str_rep)
    198     if should_extension_dispatch(lvalues, rvalues) or isinstance(rvalues, Timedelta):
    199         # Timedelta is included because numexpr will fail on it, see GH#31457
--> 200         res_values = op(lvalues, rvalues)
    201 
    202     else:

~/scipy/pandas/pandas/core/ops/common.py in new_method(self, other)
     63         other = item_from_zerodim(other)
     64 
---> 65         return method(self, other)
     66 
     67     return new_method

~/scipy/pandas/pandas/core/arrays/integer.py in integer_arithmetic_method(self, other)
    578 
    579             if getattr(other, "ndim", 0) > 1:
--> 580                 raise NotImplementedError("can only perform ops with 1-d structures")
    581 
    582             if isinstance(other, IntegerArray):

NotImplementedError: can only perform ops with 1-d structures

In [4]: df.astype(int) + s  
Out[4]: 
    a   b   c
0  86  53  66
1  77  26  56
2  11   5  45
3  97  21  84
4  20  72  38
5  62  45   7
6  91  34  20
7  26   5  98
8  18  55  66
9  86  33  80
@jorisvandenbossche jorisvandenbossche added Bug Numeric Operations Arithmetic, Comparison, and Logical operations ExtensionArray Extending pandas with custom dtypes or arrays. labels May 22, 2020
@jorisvandenbossche jorisvandenbossche added this to the Contributions Welcome milestone May 22, 2020
@jorisvandenbossche jorisvandenbossche added Regression Functionality that used to work in a prior pandas version and removed Bug labels May 22, 2020
@jorisvandenbossche jorisvandenbossche modified the milestones: Contributions Welcome, 1.1 May 22, 2020
@jorisvandenbossche
Copy link
Member Author

This is apparently a regression on master

@jorisvandenbossche
Copy link
Member Author

I suppose this was caused by #31296

@jorisvandenbossche
Copy link
Member Author

Closed by #34277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Numeric Operations Arithmetic, Comparison, and Logical operations Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant