@@ -1179,18 +1179,20 @@ def argsort(self, *args, **kwargs):
1179
1179
return result .argsort (* args , ** kwargs )
1180
1180
1181
1181
def __add__ (self , other ):
1182
- if isinstance (other , Index ):
1182
+ if com . is_list_like (other ):
1183
1183
warnings .warn ("using '+' to provide set union with Indexes is deprecated, "
1184
1184
"use '|' or .union()" ,FutureWarning )
1185
+ if isinstance (other , Index ):
1185
1186
return self .union (other )
1186
1187
return Index (np .array (self ) + other )
1187
1188
__iadd__ = __add__
1189
+ __radd__ = __add__
1188
1190
1189
1191
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 )
1193
1194
return self .difference (other )
1195
+ __rsub__ = __sub__
1194
1196
1195
1197
def __and__ (self , other ):
1196
1198
return self .intersection (other )
@@ -2481,8 +2483,8 @@ def invalid_op(self, other=None):
2481
2483
invalid_op .__name__ = name
2482
2484
return invalid_op
2483
2485
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__' )
2486
2488
2487
2489
@classmethod
2488
2490
def _add_numeric_methods_disabled (cls ):
0 commit comments