@@ -1564,14 +1564,14 @@ def _is_label_reference(self, key, axis=0):
1564
1564
-------
1565
1565
is_label: bool
1566
1566
"""
1567
- axis = self ._get_axis_number (axis )
1568
- other_axes = [ax for ax in range (self ._AXIS_LEN ) if ax != axis ]
1569
-
1570
1567
if self .ndim > 2 :
1571
1568
raise NotImplementedError (
1572
1569
"_is_label_reference is not implemented for {type}"
1573
1570
.format (type = type (self )))
1574
1571
1572
+ axis = self ._get_axis_number (axis )
1573
+ other_axes = (ax for ax in range (self ._AXIS_LEN ) if ax != axis )
1574
+
1575
1575
return (key is not None and
1576
1576
is_hashable (key ) and
1577
1577
any (key in self .axes [ax ] for ax in other_axes ))
@@ -1623,15 +1623,14 @@ def _check_label_or_level_ambiguity(self, key, axis=0):
1623
1623
------
1624
1624
ValueError: `key` is ambiguous
1625
1625
"""
1626
-
1627
- axis = self ._get_axis_number (axis )
1628
- other_axes = [ax for ax in range (self ._AXIS_LEN ) if ax != axis ]
1629
-
1630
1626
if self .ndim > 2 :
1631
1627
raise NotImplementedError (
1632
1628
"_check_label_or_level_ambiguity is not implemented for {type}"
1633
1629
.format (type = type (self )))
1634
1630
1631
+ axis = self ._get_axis_number (axis )
1632
+ other_axes = (ax for ax in range (self ._AXIS_LEN ) if ax != axis )
1633
+
1635
1634
if (key is not None and
1636
1635
is_hashable (key ) and
1637
1636
key in self .axes [axis ].names and
@@ -1689,15 +1688,14 @@ def _get_label_or_level_values(self, key, axis=0):
1689
1688
if `key` is ambiguous. This will become an ambiguity error in a
1690
1689
future version
1691
1690
"""
1692
-
1693
- axis = self ._get_axis_number (axis )
1694
- other_axes = [ax for ax in range (self ._AXIS_LEN ) if ax != axis ]
1695
-
1696
1691
if self .ndim > 2 :
1697
1692
raise NotImplementedError (
1698
1693
"_get_label_or_level_values is not implemented for {type}"
1699
1694
.format (type = type (self )))
1700
1695
1696
+ axis = self ._get_axis_number (axis )
1697
+ other_axes = [ax for ax in range (self ._AXIS_LEN ) if ax != axis ]
1698
+
1701
1699
if self ._is_label_reference (key , axis = axis ):
1702
1700
self ._check_label_or_level_ambiguity (key , axis = axis )
1703
1701
values = self .xs (key , axis = other_axes [0 ])._values
@@ -1753,14 +1751,13 @@ def _drop_labels_or_levels(self, keys, axis=0):
1753
1751
ValueError
1754
1752
if any `keys` match neither a label nor a level
1755
1753
"""
1756
-
1757
- axis = self ._get_axis_number (axis )
1758
-
1759
1754
if self .ndim > 2 :
1760
1755
raise NotImplementedError (
1761
1756
"_drop_labels_or_levels is not implemented for {type}"
1762
1757
.format (type = type (self )))
1763
1758
1759
+ axis = self ._get_axis_number (axis )
1760
+
1764
1761
# Validate keys
1765
1762
keys = com .maybe_make_list (keys )
1766
1763
invalid_keys = [k for k in keys if not
@@ -8579,7 +8576,7 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
8579
8576
cond = self ._constructor (cond , ** self ._construct_axes_dict ())
8580
8577
8581
8578
# make sure we are boolean
8582
- fill_value = True if inplace else False
8579
+ fill_value = bool ( inplace )
8583
8580
cond = cond .fillna (fill_value )
8584
8581
8585
8582
msg = "Boolean array expected for the condition, not {dtype}"
@@ -10243,8 +10240,8 @@ def last_valid_index(self):
10243
10240
10244
10241
def _doc_parms (cls ):
10245
10242
"""Return a tuple of the doc parms."""
10246
- axis_descr = "{%s}" % ', ' .join ([ "{0} ({1})" .format (a , i )
10247
- for i , a in enumerate (cls ._AXIS_ORDERS )] )
10243
+ axis_descr = "{%s}" % ', ' .join ("{0} ({1})" .format (a , i )
10244
+ for i , a in enumerate (cls ._AXIS_ORDERS ))
10248
10245
name = (cls ._constructor_sliced .__name__
10249
10246
if cls ._AXIS_LEN > 1 else 'scalar' )
10250
10247
name2 = cls .__name__
0 commit comments