@@ -150,22 +150,7 @@ def names(x):
150
150
return new_methods
151
151
152
152
153
- def add_methods (cls , new_methods , force , select , exclude ):
154
- if select and exclude :
155
- raise TypeError ("May only pass either select or exclude" )
156
-
157
- if select :
158
- select = set (select )
159
- methods = {}
160
- for key , method in new_methods .items ():
161
- if key in select :
162
- methods [key ] = method
163
- new_methods = methods
164
-
165
- if exclude :
166
- for k in exclude :
167
- new_methods .pop (k , None )
168
-
153
+ def add_methods (cls , new_methods , force ):
169
154
for name , method in new_methods .items ():
170
155
if force or name not in cls .__dict__ :
171
156
bind_method (cls , name , method )
@@ -175,8 +160,8 @@ def add_methods(cls, new_methods, force, select, exclude):
175
160
# Arithmetic
176
161
def add_special_arithmetic_methods (cls , arith_method = None ,
177
162
comp_method = None , bool_method = None ,
178
- use_numexpr = True , force = False , select = None ,
179
- exclude = None , have_divmod = False ):
163
+ use_numexpr = True , force = False ,
164
+ have_divmod = False ):
180
165
"""
181
166
Adds the full suite of special arithmetic methods (``__add__``,
182
167
``__sub__``, etc.) to the class.
@@ -195,10 +180,6 @@ def add_special_arithmetic_methods(cls, arith_method=None,
195
180
force : bool, default False
196
181
if False, checks whether function is defined **on ``cls.__dict__``**
197
182
before defining if True, always defines functions on class base
198
- select : iterable of strings (optional)
199
- if passed, only sets functions with names in select
200
- exclude : iterable of strings (optional)
201
- if passed, will not set functions with names in exclude
202
183
have_divmod : bool, (optional)
203
184
should a divmod method be added? this method is special because it
204
185
returns a tuple of cls instead of a single element of type cls
@@ -247,14 +228,12 @@ def f(self, other):
247
228
__ior__ = _wrap_inplace_method (new_methods ["__or__" ]),
248
229
__ixor__ = _wrap_inplace_method (new_methods ["__xor__" ])))
249
230
250
- add_methods (cls , new_methods = new_methods , force = force , select = select ,
251
- exclude = exclude )
231
+ add_methods (cls , new_methods = new_methods , force = force )
252
232
253
233
254
234
def add_flex_arithmetic_methods (cls , flex_arith_method ,
255
235
flex_comp_method = None , flex_bool_method = None ,
256
- use_numexpr = True , force = False , select = None ,
257
- exclude = None ):
236
+ use_numexpr = True , force = False ):
258
237
"""
259
238
Adds the full suite of flex arithmetic methods (``pow``, ``mul``, ``add``)
260
239
to the class.
@@ -271,10 +250,6 @@ def add_flex_arithmetic_methods(cls, flex_arith_method,
271
250
force : bool, default False
272
251
if False, checks whether function is defined **on ``cls.__dict__``**
273
252
before defining if True, always defines functions on class base
274
- select : iterable of strings (optional)
275
- if passed, only sets functions with names in select
276
- exclude : iterable of strings (optional)
277
- if passed, will not set functions with names in exclude
278
253
"""
279
254
# in frame, default axis is 'columns', doesn't matter for series and panel
280
255
new_methods = _create_methods (flex_arith_method ,
@@ -289,8 +264,7 @@ def add_flex_arithmetic_methods(cls, flex_arith_method,
289
264
if k in new_methods :
290
265
new_methods .pop (k )
291
266
292
- add_methods (cls , new_methods = new_methods , force = force , select = select ,
293
- exclude = exclude )
267
+ add_methods (cls , new_methods = new_methods , force = force )
294
268
295
269
296
270
def _align_method_SERIES (left , right , align_asobject = False ):
@@ -389,16 +363,16 @@ def wrapper(left, right, name=name, na_op=na_op):
389
363
return NotImplemented
390
364
391
365
left , right = _align_method_SERIES (left , right )
366
+ res_name = _get_series_op_result_name (left , right )
367
+
392
368
if is_datetime64_dtype (left ) or is_datetime64tz_dtype (left ):
393
369
result = dispatch_to_index_op (op , left , right , pd .DatetimeIndex )
394
- res_name = _get_series_op_result_name (left , right )
395
370
return construct_result (left , result ,
396
371
index = left .index , name = res_name ,
397
372
dtype = result .dtype )
398
373
399
374
elif is_timedelta64_dtype (left ):
400
375
result = dispatch_to_index_op (op , left , right , pd .TimedeltaIndex )
401
- res_name = _get_series_op_result_name (left , right )
402
376
return construct_result (left , result ,
403
377
index = left .index , name = res_name ,
404
378
dtype = result .dtype )
@@ -409,7 +383,6 @@ def wrapper(left, right, name=name, na_op=na_op):
409
383
rvalues = getattr (rvalues , 'values' , rvalues )
410
384
411
385
result = safe_na_op (lvalues , rvalues )
412
- res_name = _get_series_op_result_name (left , right )
413
386
return construct_result (left , result ,
414
387
index = left .index , name = res_name , dtype = None )
415
388
0 commit comments