Skip to content

Commit 4732363

Browse files
committed
add check if other is Series
1 parent 3e6bed7 commit 4732363

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

pandas/core/series.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6662,19 +6662,20 @@ def _logical_method(self, other, op):
66626662
return self._construct_result(res_values, name=res_name, other=other)
66636663

66646664
def _arith_method(self, other, op):
6665-
if (
6666-
isinstance(self.index, MultiIndex)
6667-
and isinstance(other.index, MultiIndex)
6668-
and self.index.names != other.index.names
6669-
):
6670-
# GH#25891
6671-
warnings.warn(
6672-
"The silent alignment on arithmetic operations between "
6673-
"'Series' with non-aligned MultiIndexes will be removed "
6674-
"in a future version, please use aligned MultiIndexes.",
6675-
Pandas4Warning,
6676-
stacklevel=find_stack_level(),
6677-
)
6665+
if isinstance(other, Series):
6666+
if (
6667+
isinstance(self.index, MultiIndex)
6668+
and isinstance(other.index, MultiIndex)
6669+
and self.index.names != other.index.names
6670+
):
6671+
# GH#25891
6672+
warnings.warn(
6673+
"The silent alignment on arithmetic operations between "
6674+
"'Series' with non-aligned MultiIndexes will be removed "
6675+
"in a future version, please align MultiIndexes.",
6676+
Pandas4Warning,
6677+
stacklevel=find_stack_level(),
6678+
)
66786679

66796680
self, other = self._align_for_op(other)
66806681
return base.IndexOpsMixin._arith_method(self, other, op)

0 commit comments

Comments
 (0)