Skip to content

BUG: bool methods are wrong with DataFrame and Series (or at least wrong error) #5035

Closed
@jtratner

Description

@jtratner
from pandas import Series, DataFrame
s = Series([2, 3, 4, 5, 6, 7, 8, 9, 10])
d = DataFrame({'a': s})
s + d
d + s
print(d & s)

produces Traceback:

raceback (most recent call last):
  File "testcase2.py", line 6, in <module>
    print(d & s)
  File "../pandas/core/frame.py", line 217, in f
    return self._combine_series(other, na_op, fill_value, axis, level)
  File "../pandas/core/frame.py", line 3040, in _combine_series
    return self._combine_match_columns(other, func, fill_value)
  File "../pandas/core/frame.py", line 3079, in _combine_match_columns
    func, right, axes=[left.columns, self.index])
  File "../pandas/core/internals.py", line 2048, in eval
    return self.apply('eval', *args, **kwargs)
  File "../pandas/core/internals.py", line 2033, in apply
    applied = getattr(blk, f)(*args, **kwargs)
  File "../pandas/core/internals.py", line 850, in eval
    result = get_result(other)
  File "../pandas/core/internals.py", line 834, in get_result
    return self._try_coerce_result(func(values, other))
  File "../pandas/core/frame.py", line 201, in na_op
    mask = notnull(xrav) & notnull(yrav)
ValueError: operands could not be broadcast together with shapes (81) (9)

s & d currently raises NotImplemented instead. (because there's no __rand__)

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDtype ConversionsUnexpected or buggy dtype conversionsInternalsRelated to non-user accessible pandas implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions