@@ -45,7 +45,6 @@ def _get_method_wrappers(cls):
45
45
# are no longer in __init__
46
46
from pandas .core .ops import (
47
47
arith_method_FRAME ,
48
- arith_method_SERIES ,
49
48
comp_method_FRAME ,
50
49
flex_comp_method_FRAME ,
51
50
flex_method_SERIES ,
@@ -55,7 +54,7 @@ def _get_method_wrappers(cls):
55
54
# Just Series
56
55
arith_flex = flex_method_SERIES
57
56
comp_flex = flex_method_SERIES
58
- arith_special = arith_method_SERIES
57
+ arith_special = None
59
58
comp_special = None
60
59
bool_special = None
61
60
elif issubclass (cls , ABCDataFrame ):
@@ -105,20 +104,19 @@ def f(self, other):
105
104
f .__name__ = f"__i{ name } __"
106
105
return f
107
106
108
- new_methods .update (
109
- dict (
110
- __iadd__ = _wrap_inplace_method (new_methods ["__add__" ]),
111
- __isub__ = _wrap_inplace_method (new_methods ["__sub__" ]),
112
- __imul__ = _wrap_inplace_method (new_methods ["__mul__" ]),
113
- __itruediv__ = _wrap_inplace_method (new_methods ["__truediv__" ]),
114
- __ifloordiv__ = _wrap_inplace_method (new_methods ["__floordiv__" ]),
115
- __imod__ = _wrap_inplace_method (new_methods ["__mod__" ]),
116
- __ipow__ = _wrap_inplace_method (new_methods ["__pow__" ]),
117
- )
118
- )
119
-
120
107
if bool_method is None :
121
- # Series gets bool_method via OpsMixin
108
+ # Series gets bool_method, arith_method via OpsMixin
109
+ new_methods .update (
110
+ dict (
111
+ __iadd__ = _wrap_inplace_method (cls .__add__ ),
112
+ __isub__ = _wrap_inplace_method (cls .__sub__ ),
113
+ __imul__ = _wrap_inplace_method (cls .__mul__ ),
114
+ __itruediv__ = _wrap_inplace_method (cls .__truediv__ ),
115
+ __ifloordiv__ = _wrap_inplace_method (cls .__floordiv__ ),
116
+ __imod__ = _wrap_inplace_method (cls .__mod__ ),
117
+ __ipow__ = _wrap_inplace_method (cls .__pow__ ),
118
+ )
119
+ )
122
120
new_methods .update (
123
121
dict (
124
122
__iand__ = _wrap_inplace_method (cls .__and__ ),
@@ -127,6 +125,17 @@ def f(self, other):
127
125
)
128
126
)
129
127
else :
128
+ new_methods .update (
129
+ dict (
130
+ __iadd__ = _wrap_inplace_method (new_methods ["__add__" ]),
131
+ __isub__ = _wrap_inplace_method (new_methods ["__sub__" ]),
132
+ __imul__ = _wrap_inplace_method (new_methods ["__mul__" ]),
133
+ __itruediv__ = _wrap_inplace_method (new_methods ["__truediv__" ]),
134
+ __ifloordiv__ = _wrap_inplace_method (new_methods ["__floordiv__" ]),
135
+ __imod__ = _wrap_inplace_method (new_methods ["__mod__" ]),
136
+ __ipow__ = _wrap_inplace_method (new_methods ["__pow__" ]),
137
+ )
138
+ )
130
139
new_methods .update (
131
140
dict (
132
141
__iand__ = _wrap_inplace_method (new_methods ["__and__" ]),
@@ -172,30 +181,34 @@ def _create_methods(cls, arith_method, comp_method, bool_method, special):
172
181
have_divmod = issubclass (cls , ABCSeries )
173
182
# divmod is available for Series
174
183
175
- new_methods = dict (
176
- add = arith_method (cls , operator .add , special ),
177
- radd = arith_method (cls , radd , special ),
178
- sub = arith_method (cls , operator .sub , special ),
179
- mul = arith_method (cls , operator .mul , special ),
180
- truediv = arith_method (cls , operator .truediv , special ),
181
- floordiv = arith_method (cls , operator .floordiv , special ),
182
- mod = arith_method (cls , operator .mod , special ),
183
- pow = arith_method (cls , operator .pow , special ),
184
- # not entirely sure why this is necessary, but previously was included
185
- # so it's here to maintain compatibility
186
- rmul = arith_method (cls , rmul , special ),
187
- rsub = arith_method (cls , rsub , special ),
188
- rtruediv = arith_method (cls , rtruediv , special ),
189
- rfloordiv = arith_method (cls , rfloordiv , special ),
190
- rpow = arith_method (cls , rpow , special ),
191
- rmod = arith_method (cls , rmod , special ),
192
- )
193
- new_methods ["div" ] = new_methods ["truediv" ]
194
- new_methods ["rdiv" ] = new_methods ["rtruediv" ]
195
- if have_divmod :
196
- # divmod doesn't have an op that is supported by numexpr
197
- new_methods ["divmod" ] = arith_method (cls , divmod , special )
198
- new_methods ["rdivmod" ] = arith_method (cls , rdivmod , special )
184
+ new_methods = {}
185
+ if arith_method is not None :
186
+ new_methods .update (
187
+ dict (
188
+ add = arith_method (cls , operator .add , special ),
189
+ radd = arith_method (cls , radd , special ),
190
+ sub = arith_method (cls , operator .sub , special ),
191
+ mul = arith_method (cls , operator .mul , special ),
192
+ truediv = arith_method (cls , operator .truediv , special ),
193
+ floordiv = arith_method (cls , operator .floordiv , special ),
194
+ mod = arith_method (cls , operator .mod , special ),
195
+ pow = arith_method (cls , operator .pow , special ),
196
+ # not entirely sure why this is necessary, but previously was included
197
+ # so it's here to maintain compatibility
198
+ rmul = arith_method (cls , rmul , special ),
199
+ rsub = arith_method (cls , rsub , special ),
200
+ rtruediv = arith_method (cls , rtruediv , special ),
201
+ rfloordiv = arith_method (cls , rfloordiv , special ),
202
+ rpow = arith_method (cls , rpow , special ),
203
+ rmod = arith_method (cls , rmod , special ),
204
+ )
205
+ )
206
+ new_methods ["div" ] = new_methods ["truediv" ]
207
+ new_methods ["rdiv" ] = new_methods ["rtruediv" ]
208
+ if have_divmod :
209
+ # divmod doesn't have an op that is supported by numexpr
210
+ new_methods ["divmod" ] = arith_method (cls , divmod , special )
211
+ new_methods ["rdivmod" ] = arith_method (cls , rdivmod , special )
199
212
200
213
if comp_method is not None :
201
214
# Series already has this pinned
@@ -210,7 +223,7 @@ def _create_methods(cls, arith_method, comp_method, bool_method, special):
210
223
)
211
224
)
212
225
213
- if bool_method :
226
+ if bool_method is not None :
214
227
new_methods .update (
215
228
dict (
216
229
and_ = bool_method (cls , operator .and_ , special ),
0 commit comments