|
13 | 13 | _get_combined_index)
|
14 | 14 | from pandas.core.indexing import _NDFrameIndexer, _maybe_droplevels
|
15 | 15 | from pandas.core.internals import BlockManager, make_block, form_blocks
|
| 16 | +from pandas.core.series import Series |
16 | 17 | from pandas.core.frame import DataFrame
|
17 | 18 | from pandas.core.generic import NDFrame
|
18 | 19 | from pandas.util import py3compat
|
@@ -152,6 +153,8 @@ def na_op(x, y):
|
152 | 153 | def f(self, other):
|
153 | 154 | if isinstance(other, self._constructor):
|
154 | 155 | return self._compare_constructor(other, func)
|
| 156 | + elif isinstance(other, (self._constructor_sliced, DataFrame, Series)): |
| 157 | + raise Exception("input needs alignment for this object [%s]" % self._constructor) |
155 | 158 | else:
|
156 | 159 | return self._combine_const(other, na_op)
|
157 | 160 |
|
@@ -443,6 +446,10 @@ def _indexed_same(self, other):
|
443 | 446 | return all([ getattr(self,a).equals(getattr(other,a)) for a in self._AXIS_ORDERS ])
|
444 | 447 |
|
445 | 448 | def _compare_constructor(self, other, func):
|
| 449 | + if not self._indexed_same(other): |
| 450 | + raise Exception('Can only compare identically-labeled ' |
| 451 | + 'same type objects') |
| 452 | + |
446 | 453 | new_data = {}
|
447 | 454 | for col in getattr(self,self._info_axis):
|
448 | 455 | new_data[col] = func(self[col], other[col])
|
|
0 commit comments