@@ -971,9 +971,9 @@ def _arith_method_SERIES(cls, op, special):
971
971
code duplication.
972
972
"""
973
973
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 )
977
977
construct_result = (_construct_divmod_result
978
978
if op is divmod else _construct_result )
979
979
@@ -996,7 +996,7 @@ def na_op(x, y):
996
996
997
997
result , changed = maybe_upcast_putmask (result , ~ mask , np .nan )
998
998
999
- result = missing .fill_zeros (result , x , y , name , fill_zeros )
999
+ result = missing .fill_zeros (result , x , y , op_name , fill_zeros )
1000
1000
return result
1001
1001
1002
1002
def safe_na_op (lvalues , rvalues ):
@@ -1009,7 +1009,7 @@ def safe_na_op(lvalues, rvalues):
1009
1009
lambda x : op (x , rvalues ))
1010
1010
raise
1011
1011
1012
- def wrapper (left , right , name = name , na_op = na_op ):
1012
+ def wrapper (left , right ):
1013
1013
1014
1014
if isinstance (right , ABCDataFrame ):
1015
1015
return NotImplemented
@@ -1100,8 +1100,8 @@ def _comp_method_SERIES(cls, op, special):
1100
1100
Wrapper function for Series arithmetic operations, to avoid
1101
1101
code duplication.
1102
1102
"""
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 )
1105
1105
1106
1106
def na_op (x , y ):
1107
1107
@@ -1133,7 +1133,7 @@ def na_op(x, y):
1133
1133
y = y .view ('i8' )
1134
1134
x = x .view ('i8' )
1135
1135
1136
- method = getattr (x , name , None )
1136
+ method = getattr (x , op_name , None )
1137
1137
if method is not None :
1138
1138
with np .errstate (all = 'ignore' ):
1139
1139
result = method (y )
@@ -1217,7 +1217,7 @@ def wrapper(self, other, axis=None):
1217
1217
else :
1218
1218
res_values = np .zeros (len (self ), dtype = bool )
1219
1219
return self ._constructor (res_values , index = self .index ,
1220
- name = self . name , dtype = 'bool' )
1220
+ name = res_name , dtype = 'bool' )
1221
1221
1222
1222
else :
1223
1223
values = self .get_values ()
@@ -1232,8 +1232,8 @@ def wrapper(self, other, axis=None):
1232
1232
1233
1233
# always return a full value series here
1234
1234
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' )
1237
1237
1238
1238
return wrapper
1239
1239
@@ -1430,10 +1430,10 @@ def to_series(right):
1430
1430
1431
1431
def _arith_method_FRAME (cls , op , special ):
1432
1432
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 )
1437
1437
1438
1438
def na_op (x , y ):
1439
1439
import pandas .core .computation .expressions as expressions
@@ -1443,7 +1443,7 @@ def na_op(x, y):
1443
1443
except TypeError :
1444
1444
xrav = x .ravel ()
1445
1445
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 ])
1447
1447
result = np .empty (x .size , dtype = dtype )
1448
1448
yrav = y .ravel ()
1449
1449
mask = notna (xrav ) & notna (yrav )
@@ -1471,20 +1471,20 @@ def na_op(x, y):
1471
1471
else :
1472
1472
raise TypeError ("cannot perform operation {op} between "
1473
1473
"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 )))
1475
1475
1476
1476
result , changed = maybe_upcast_putmask (result , ~ mask , np .nan )
1477
1477
result = result .reshape (x .shape )
1478
1478
1479
- result = missing .fill_zeros (result , x , y , name , fill_zeros )
1479
+ result = missing .fill_zeros (result , x , y , op_name , fill_zeros )
1480
1480
1481
1481
return result
1482
1482
1483
- if name in _op_descriptions :
1483
+ if op_name in _op_descriptions :
1484
1484
# i.e. include "add" but not "__add__"
1485
- doc = _make_flex_doc (name , 'dataframe' )
1485
+ doc = _make_flex_doc (op_name , 'dataframe' )
1486
1486
else :
1487
- doc = _arith_doc_FRAME % name
1487
+ doc = _arith_doc_FRAME % op_name
1488
1488
1489
1489
@Appender (doc )
1490
1490
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):
1503
1503
1504
1504
return self ._combine_const (other , na_op , try_cast = True )
1505
1505
1506
- f .__name__ = name
1506
+ f .__name__ = op_name
1507
1507
1508
1508
return f
1509
1509
1510
1510
1511
1511
def _flex_comp_method_FRAME (cls , op , special ):
1512
1512
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 )
1515
1515
1516
1516
def na_op (x , y ):
1517
1517
try :
@@ -1522,7 +1522,7 @@ def na_op(x, y):
1522
1522
return result
1523
1523
1524
1524
@Appender ('Wrapper for flexible comparison methods {name}'
1525
- .format (name = name ))
1525
+ .format (name = op_name ))
1526
1526
def f (self , other , axis = default_axis , level = None ):
1527
1527
1528
1528
other = _align_method_FRAME (self , other , axis )
@@ -1541,16 +1541,16 @@ def f(self, other, axis=default_axis, level=None):
1541
1541
else :
1542
1542
return self ._combine_const (other , na_op , try_cast = False )
1543
1543
1544
- f .__name__ = name
1544
+ f .__name__ = op_name
1545
1545
1546
1546
return f
1547
1547
1548
1548
1549
1549
def _comp_method_FRAME (cls , func , special ):
1550
1550
str_rep = _get_opstr (func , cls )
1551
- name = _get_op_name (func , special )
1551
+ op_name = _get_op_name (func , special )
1552
1552
1553
- @Appender ('Wrapper for comparison method {name}' .format (name = name ))
1553
+ @Appender ('Wrapper for comparison method {name}' .format (name = op_name ))
1554
1554
def f (self , other ):
1555
1555
if isinstance (other , ABCDataFrame ):
1556
1556
# Another DataFrame
@@ -1572,7 +1572,7 @@ def f(self, other):
1572
1572
try_cast = False )
1573
1573
return res .fillna (True ).astype (bool )
1574
1574
1575
- f .__name__ = name
1575
+ f .__name__ = op_name
1576
1576
1577
1577
return f
1578
1578
@@ -1582,7 +1582,7 @@ def f(self, other):
1582
1582
1583
1583
def _arith_method_PANEL (cls , op , special ):
1584
1584
# work only for scalars
1585
- name = _get_op_name (op , special )
1585
+ op_name = _get_op_name (op , special )
1586
1586
1587
1587
def f (self , other ):
1588
1588
if not is_scalar (other ):
@@ -1592,13 +1592,13 @@ def f(self, other):
1592
1592
1593
1593
return self ._combine (other , op )
1594
1594
1595
- f .__name__ = name
1595
+ f .__name__ = op_name
1596
1596
return f
1597
1597
1598
1598
1599
1599
def _comp_method_PANEL (cls , op , special ):
1600
1600
str_rep = _get_opstr (op , cls )
1601
- name = _get_op_name (op , special )
1601
+ op_name = _get_op_name (op , special )
1602
1602
1603
1603
def na_op (x , y ):
1604
1604
import pandas .core .computation .expressions as expressions
@@ -1609,7 +1609,7 @@ def na_op(x, y):
1609
1609
result = mask_cmp_op (x , y , op , np .ndarray )
1610
1610
return result
1611
1611
1612
- @Appender ('Wrapper for comparison method {name}' .format (name = name ))
1612
+ @Appender ('Wrapper for comparison method {name}' .format (name = op_name ))
1613
1613
def f (self , other , axis = None ):
1614
1614
# Validate the axis parameter
1615
1615
if axis is not None :
@@ -1624,16 +1624,16 @@ def f(self, other, axis=None):
1624
1624
else :
1625
1625
return self ._combine_const (other , na_op , try_cast = False )
1626
1626
1627
- f .__name__ = name
1627
+ f .__name__ = op_name
1628
1628
1629
1629
return f
1630
1630
1631
1631
1632
1632
def _flex_method_PANEL (cls , op , special ):
1633
1633
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 )
1637
1637
1638
1638
def na_op (x , y ):
1639
1639
import pandas .core .computation .expressions as expressions
@@ -1648,20 +1648,20 @@ def na_op(x, y):
1648
1648
# handles discrepancy between numpy and numexpr on division/mod
1649
1649
# by 0 though, given that these are generally (always?)
1650
1650
# 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 )
1652
1652
return result
1653
1653
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' )
1656
1656
else :
1657
1657
# doc strings substitors
1658
- doc = _agg_doc_PANEL .format (op_name = name )
1658
+ doc = _agg_doc_PANEL .format (op_name = op_name )
1659
1659
1660
1660
@Appender (doc )
1661
1661
def f (self , other , axis = 0 ):
1662
1662
return self ._combine (other , na_op , axis = axis )
1663
1663
1664
- f .__name__ = name
1664
+ f .__name__ = op_name
1665
1665
return f
1666
1666
1667
1667
@@ -1703,15 +1703,15 @@ def _arith_method_SPARSE_SERIES(cls, op, special):
1703
1703
Wrapper function for Series arithmetic operations, to avoid
1704
1704
code duplication.
1705
1705
"""
1706
- name = _get_op_name (op , special )
1706
+ op_name = _get_op_name (op , special )
1707
1707
1708
1708
def wrapper (self , other ):
1709
1709
if isinstance (other , ABCDataFrame ):
1710
1710
return NotImplemented
1711
1711
elif isinstance (other , ABCSeries ):
1712
1712
if not isinstance (other , ABCSparseSeries ):
1713
1713
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 )
1715
1715
elif is_scalar (other ):
1716
1716
with np .errstate (all = 'ignore' ):
1717
1717
new_values = op (self .values , other )
@@ -1722,7 +1722,7 @@ def wrapper(self, other):
1722
1722
raise TypeError ('operation with {other} not supported'
1723
1723
.format (other = type (other )))
1724
1724
1725
- wrapper .__name__ = name
1725
+ wrapper .__name__ = op_name
1726
1726
return wrapper
1727
1727
1728
1728
@@ -1742,7 +1742,7 @@ def _arith_method_SPARSE_ARRAY(cls, op, special):
1742
1742
Wrapper function for Series arithmetic operations, to avoid
1743
1743
code duplication.
1744
1744
"""
1745
- name = _get_op_name (op , special )
1745
+ op_name = _get_op_name (op , special )
1746
1746
1747
1747
def wrapper (self , other ):
1748
1748
from pandas .core .sparse .array import (
@@ -1755,16 +1755,16 @@ def wrapper(self, other):
1755
1755
dtype = getattr (other , 'dtype' , None )
1756
1756
other = SparseArray (other , fill_value = self .fill_value ,
1757
1757
dtype = dtype )
1758
- return _sparse_array_op (self , other , op , name )
1758
+ return _sparse_array_op (self , other , op , op_name )
1759
1759
elif is_scalar (other ):
1760
1760
with np .errstate (all = 'ignore' ):
1761
1761
fill = op (_get_fill (self ), np .asarray (other ))
1762
1762
result = op (self .sp_values , other )
1763
1763
1764
- return _wrap_result (name , result , self .sp_index , fill )
1764
+ return _wrap_result (op_name , result , self .sp_index , fill )
1765
1765
else : # pragma: no cover
1766
1766
raise TypeError ('operation with {other} not supported'
1767
1767
.format (other = type (other )))
1768
1768
1769
- wrapper .__name__ = name
1769
+ wrapper .__name__ = op_name
1770
1770
return wrapper
0 commit comments