@@ -971,9 +971,9 @@ def _arith_method_SERIES(cls, op, special):
971971 code duplication.
972972 """
973973 str_rep = _get_opstr (op , cls )
974- name = _get_op_name (op , special )
975- eval_kwargs = _gen_eval_kwargs (name )
976- fill_zeros = _gen_fill_zeros (name )
974+ op_name = _get_op_name (op , special )
975+ eval_kwargs = _gen_eval_kwargs (op_name )
976+ fill_zeros = _gen_fill_zeros (op_name )
977977 construct_result = (_construct_divmod_result
978978 if op is divmod else _construct_result )
979979
@@ -996,7 +996,7 @@ def na_op(x, y):
996996
997997 result , changed = maybe_upcast_putmask (result , ~ mask , np .nan )
998998
999- result = missing .fill_zeros (result , x , y , name , fill_zeros )
999+ result = missing .fill_zeros (result , x , y , op_name , fill_zeros )
10001000 return result
10011001
10021002 def safe_na_op (lvalues , rvalues ):
@@ -1009,7 +1009,7 @@ def safe_na_op(lvalues, rvalues):
10091009 lambda x : op (x , rvalues ))
10101010 raise
10111011
1012- def wrapper (left , right , name = name , na_op = na_op ):
1012+ def wrapper (left , right ):
10131013
10141014 if isinstance (right , ABCDataFrame ):
10151015 return NotImplemented
@@ -1100,8 +1100,8 @@ def _comp_method_SERIES(cls, op, special):
11001100 Wrapper function for Series arithmetic operations, to avoid
11011101 code duplication.
11021102 """
1103- name = _get_op_name (op , special )
1104- masker = _gen_eval_kwargs (name ).get ('masker' , False )
1103+ op_name = _get_op_name (op , special )
1104+ masker = _gen_eval_kwargs (op_name ).get ('masker' , False )
11051105
11061106 def na_op (x , y ):
11071107
@@ -1133,7 +1133,7 @@ def na_op(x, y):
11331133 y = y .view ('i8' )
11341134 x = x .view ('i8' )
11351135
1136- method = getattr (x , name , None )
1136+ method = getattr (x , op_name , None )
11371137 if method is not None :
11381138 with np .errstate (all = 'ignore' ):
11391139 result = method (y )
@@ -1217,7 +1217,7 @@ def wrapper(self, other, axis=None):
12171217 else :
12181218 res_values = np .zeros (len (self ), dtype = bool )
12191219 return self ._constructor (res_values , index = self .index ,
1220- name = self . name , dtype = 'bool' )
1220+ name = res_name , dtype = 'bool' )
12211221
12221222 else :
12231223 values = self .get_values ()
@@ -1232,8 +1232,8 @@ def wrapper(self, other, axis=None):
12321232
12331233 # always return a full value series here
12341234 res_values = com ._values_from_object (res )
1235- return pd . Series (res_values , index = self .index ,
1236- name = res_name , dtype = 'bool' )
1235+ return self . _constructor (res_values , index = self .index ,
1236+ name = res_name , dtype = 'bool' )
12371237
12381238 return wrapper
12391239
@@ -1430,10 +1430,10 @@ def to_series(right):
14301430
14311431def _arith_method_FRAME (cls , op , special ):
14321432 str_rep = _get_opstr (op , cls )
1433- name = _get_op_name (op , special )
1434- eval_kwargs = _gen_eval_kwargs (name )
1435- fill_zeros = _gen_fill_zeros (name )
1436- default_axis = _get_frame_op_default_axis (name )
1433+ op_name = _get_op_name (op , special )
1434+ eval_kwargs = _gen_eval_kwargs (op_name )
1435+ fill_zeros = _gen_fill_zeros (op_name )
1436+ default_axis = _get_frame_op_default_axis (op_name )
14371437
14381438 def na_op (x , y ):
14391439 import pandas .core .computation .expressions as expressions
@@ -1443,7 +1443,7 @@ def na_op(x, y):
14431443 except TypeError :
14441444 xrav = x .ravel ()
14451445 if isinstance (y , (np .ndarray , ABCSeries )):
1446- dtype = np . find_common_type ([x .dtype , y .dtype ], [ ])
1446+ dtype = find_common_type ([x .dtype , y .dtype ])
14471447 result = np .empty (x .size , dtype = dtype )
14481448 yrav = y .ravel ()
14491449 mask = notna (xrav ) & notna (yrav )
@@ -1471,20 +1471,20 @@ def na_op(x, y):
14711471 else :
14721472 raise TypeError ("cannot perform operation {op} between "
14731473 "objects of type {x} and {y}"
1474- .format (op = name , x = type (x ), y = type (y )))
1474+ .format (op = op_name , x = type (x ), y = type (y )))
14751475
14761476 result , changed = maybe_upcast_putmask (result , ~ mask , np .nan )
14771477 result = result .reshape (x .shape )
14781478
1479- result = missing .fill_zeros (result , x , y , name , fill_zeros )
1479+ result = missing .fill_zeros (result , x , y , op_name , fill_zeros )
14801480
14811481 return result
14821482
1483- if name in _op_descriptions :
1483+ if op_name in _op_descriptions :
14841484 # i.e. include "add" but not "__add__"
1485- doc = _make_flex_doc (name , 'dataframe' )
1485+ doc = _make_flex_doc (op_name , 'dataframe' )
14861486 else :
1487- doc = _arith_doc_FRAME % name
1487+ doc = _arith_doc_FRAME % op_name
14881488
14891489 @Appender (doc )
14901490 def f (self , other , axis = default_axis , level = None , fill_value = None ):
@@ -1503,15 +1503,15 @@ def f(self, other, axis=default_axis, level=None, fill_value=None):
15031503
15041504 return self ._combine_const (other , na_op , try_cast = True )
15051505
1506- f .__name__ = name
1506+ f .__name__ = op_name
15071507
15081508 return f
15091509
15101510
15111511def _flex_comp_method_FRAME (cls , op , special ):
15121512 str_rep = _get_opstr (op , cls )
1513- name = _get_op_name (op , special )
1514- default_axis = _get_frame_op_default_axis (name )
1513+ op_name = _get_op_name (op , special )
1514+ default_axis = _get_frame_op_default_axis (op_name )
15151515
15161516 def na_op (x , y ):
15171517 try :
@@ -1522,7 +1522,7 @@ def na_op(x, y):
15221522 return result
15231523
15241524 @Appender ('Wrapper for flexible comparison methods {name}'
1525- .format (name = name ))
1525+ .format (name = op_name ))
15261526 def f (self , other , axis = default_axis , level = None ):
15271527
15281528 other = _align_method_FRAME (self , other , axis )
@@ -1541,16 +1541,16 @@ def f(self, other, axis=default_axis, level=None):
15411541 else :
15421542 return self ._combine_const (other , na_op , try_cast = False )
15431543
1544- f .__name__ = name
1544+ f .__name__ = op_name
15451545
15461546 return f
15471547
15481548
15491549def _comp_method_FRAME (cls , func , special ):
15501550 str_rep = _get_opstr (func , cls )
1551- name = _get_op_name (func , special )
1551+ op_name = _get_op_name (func , special )
15521552
1553- @Appender ('Wrapper for comparison method {name}' .format (name = name ))
1553+ @Appender ('Wrapper for comparison method {name}' .format (name = op_name ))
15541554 def f (self , other ):
15551555 if isinstance (other , ABCDataFrame ):
15561556 # Another DataFrame
@@ -1572,7 +1572,7 @@ def f(self, other):
15721572 try_cast = False )
15731573 return res .fillna (True ).astype (bool )
15741574
1575- f .__name__ = name
1575+ f .__name__ = op_name
15761576
15771577 return f
15781578
@@ -1582,7 +1582,7 @@ def f(self, other):
15821582
15831583def _arith_method_PANEL (cls , op , special ):
15841584 # work only for scalars
1585- name = _get_op_name (op , special )
1585+ op_name = _get_op_name (op , special )
15861586
15871587 def f (self , other ):
15881588 if not is_scalar (other ):
@@ -1592,13 +1592,13 @@ def f(self, other):
15921592
15931593 return self ._combine (other , op )
15941594
1595- f .__name__ = name
1595+ f .__name__ = op_name
15961596 return f
15971597
15981598
15991599def _comp_method_PANEL (cls , op , special ):
16001600 str_rep = _get_opstr (op , cls )
1601- name = _get_op_name (op , special )
1601+ op_name = _get_op_name (op , special )
16021602
16031603 def na_op (x , y ):
16041604 import pandas .core .computation .expressions as expressions
@@ -1609,7 +1609,7 @@ def na_op(x, y):
16091609 result = mask_cmp_op (x , y , op , np .ndarray )
16101610 return result
16111611
1612- @Appender ('Wrapper for comparison method {name}' .format (name = name ))
1612+ @Appender ('Wrapper for comparison method {name}' .format (name = op_name ))
16131613 def f (self , other , axis = None ):
16141614 # Validate the axis parameter
16151615 if axis is not None :
@@ -1624,16 +1624,16 @@ def f(self, other, axis=None):
16241624 else :
16251625 return self ._combine_const (other , na_op , try_cast = False )
16261626
1627- f .__name__ = name
1627+ f .__name__ = op_name
16281628
16291629 return f
16301630
16311631
16321632def _flex_method_PANEL (cls , op , special ):
16331633 str_rep = _get_opstr (op , cls )
1634- name = _get_op_name (op , special )
1635- eval_kwargs = _gen_eval_kwargs (name )
1636- fill_zeros = _gen_fill_zeros (name )
1634+ op_name = _get_op_name (op , special )
1635+ eval_kwargs = _gen_eval_kwargs (op_name )
1636+ fill_zeros = _gen_fill_zeros (op_name )
16371637
16381638 def na_op (x , y ):
16391639 import pandas .core .computation .expressions as expressions
@@ -1648,20 +1648,20 @@ def na_op(x, y):
16481648 # handles discrepancy between numpy and numexpr on division/mod
16491649 # by 0 though, given that these are generally (always?)
16501650 # non-scalars, I'm not sure whether it's worth it at the moment
1651- result = missing .fill_zeros (result , x , y , name , fill_zeros )
1651+ result = missing .fill_zeros (result , x , y , op_name , fill_zeros )
16521652 return result
16531653
1654- if name in _op_descriptions :
1655- doc = _make_flex_doc (name , 'panel' )
1654+ if op_name in _op_descriptions :
1655+ doc = _make_flex_doc (op_name , 'panel' )
16561656 else :
16571657 # doc strings substitors
1658- doc = _agg_doc_PANEL .format (op_name = name )
1658+ doc = _agg_doc_PANEL .format (op_name = op_name )
16591659
16601660 @Appender (doc )
16611661 def f (self , other , axis = 0 ):
16621662 return self ._combine (other , na_op , axis = axis )
16631663
1664- f .__name__ = name
1664+ f .__name__ = op_name
16651665 return f
16661666
16671667
@@ -1703,15 +1703,15 @@ def _arith_method_SPARSE_SERIES(cls, op, special):
17031703 Wrapper function for Series arithmetic operations, to avoid
17041704 code duplication.
17051705 """
1706- name = _get_op_name (op , special )
1706+ op_name = _get_op_name (op , special )
17071707
17081708 def wrapper (self , other ):
17091709 if isinstance (other , ABCDataFrame ):
17101710 return NotImplemented
17111711 elif isinstance (other , ABCSeries ):
17121712 if not isinstance (other , ABCSparseSeries ):
17131713 other = other .to_sparse (fill_value = self .fill_value )
1714- return _sparse_series_op (self , other , op , name )
1714+ return _sparse_series_op (self , other , op , op_name )
17151715 elif is_scalar (other ):
17161716 with np .errstate (all = 'ignore' ):
17171717 new_values = op (self .values , other )
@@ -1722,7 +1722,7 @@ def wrapper(self, other):
17221722 raise TypeError ('operation with {other} not supported'
17231723 .format (other = type (other )))
17241724
1725- wrapper .__name__ = name
1725+ wrapper .__name__ = op_name
17261726 return wrapper
17271727
17281728
@@ -1742,7 +1742,7 @@ def _arith_method_SPARSE_ARRAY(cls, op, special):
17421742 Wrapper function for Series arithmetic operations, to avoid
17431743 code duplication.
17441744 """
1745- name = _get_op_name (op , special )
1745+ op_name = _get_op_name (op , special )
17461746
17471747 def wrapper (self , other ):
17481748 from pandas .core .sparse .array import (
@@ -1755,16 +1755,16 @@ def wrapper(self, other):
17551755 dtype = getattr (other , 'dtype' , None )
17561756 other = SparseArray (other , fill_value = self .fill_value ,
17571757 dtype = dtype )
1758- return _sparse_array_op (self , other , op , name )
1758+ return _sparse_array_op (self , other , op , op_name )
17591759 elif is_scalar (other ):
17601760 with np .errstate (all = 'ignore' ):
17611761 fill = op (_get_fill (self ), np .asarray (other ))
17621762 result = op (self .sp_values , other )
17631763
1764- return _wrap_result (name , result , self .sp_index , fill )
1764+ return _wrap_result (op_name , result , self .sp_index , fill )
17651765 else : # pragma: no cover
17661766 raise TypeError ('operation with {other} not supported'
17671767 .format (other = type (other )))
17681768
1769- wrapper .__name__ = name
1769+ wrapper .__name__ = op_name
17701770 return wrapper
0 commit comments