Closed
Description
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__
)
Activity
jreback commentedon Sep 29, 2013
I don't think this implemented per se, may have to manually broadcast the operands (the numeric ops might do this, not sure why bool not)
jtratner commentedon Sep 29, 2013
It's weird, bool and numeric use the same
_arith_method
too.jtratner commentedon Sep 29, 2013
Similarly, how about this, is this right?
cpcloud commentedon Sep 29, 2013
it aligns on the oclumns by default, and
ser
doesn't havea
in its indexcpcloud commentedon Sep 29, 2013
so yes it's correct
cpcloud commentedon Sep 29, 2013
to align on the index u have to do:
jreback commentedon Sep 29, 2013
0.14 or 0.13?
jtratner commentedon Sep 29, 2013
well, it's long-standing, so probably fine to push to 0.14.