@@ -1179,18 +1179,20 @@ def argsort(self, *args, **kwargs):
11791179 return result .argsort (* args , ** kwargs )
11801180
11811181 def __add__ (self , other ):
1182- if isinstance (other , Index ):
1182+ if com . is_list_like (other ):
11831183 warnings .warn ("using '+' to provide set union with Indexes is deprecated, "
11841184 "use '|' or .union()" ,FutureWarning )
1185+ if isinstance (other , Index ):
11851186 return self .union (other )
11861187 return Index (np .array (self ) + other )
11871188 __iadd__ = __add__
1189+ __radd__ = __add__
11881190
11891191 def __sub__ (self , other ):
1190- if isinstance (other , Index ):
1191- warnings .warn ("using '-' to provide set differences with Indexes is deprecated, "
1192- "use .difference()" ,FutureWarning )
1192+ warnings .warn ("using '-' to provide set differences with Indexes is deprecated, "
1193+ "use .difference()" ,FutureWarning )
11931194 return self .difference (other )
1195+ __rsub__ = __sub__
11941196
11951197 def __and__ (self , other ):
11961198 return self .intersection (other )
@@ -2481,8 +2483,8 @@ def invalid_op(self, other=None):
24812483 invalid_op .__name__ = name
24822484 return invalid_op
24832485
2484- cls .__add__ = cls .__add__ = __iadd__ = _make_invalid_op ('__add__' )
2485- cls .__sub__ = cls .__sub__ = __isub__ = _make_invalid_op ('__sub__' )
2486+ cls .__add__ = cls .__radd__ = __iadd__ = _make_invalid_op ('__add__' )
2487+ cls .__sub__ = cls .__rsub__ = __isub__ = _make_invalid_op ('__sub__' )
24862488
24872489 @classmethod
24882490 def _add_numeric_methods_disabled (cls ):
0 commit comments