@@ -222,12 +222,6 @@ def make_block(self, values, placement=None, ndim=None):
222
222
223
223
return make_block (values , placement = placement , ndim = ndim )
224
224
225
- def make_block_scalar (self , values ):
226
- """
227
- Create a ScalarBlock
228
- """
229
- return ScalarBlock (values )
230
-
231
225
def make_block_same_class (self , values , placement = None , ndim = None ,
232
226
dtype = None ):
233
227
""" Wrap given values in a block of same type as self. """
@@ -1468,13 +1462,15 @@ def quantile(self, qs, interpolation='linear', axis=0):
1468
1462
else :
1469
1463
# create the array of na_values
1470
1464
# 2d len(values) * len(qs)
1471
- result = np .repeat (np .array ([self ._na_value ] * len (qs )),
1465
+ result = np .repeat (np .array ([self .fill_value ] * len (qs )),
1472
1466
len (values )).reshape (len (values ),
1473
1467
len (qs ))
1474
1468
else :
1475
- mask = isna (self .values )
1469
+ # asarray needed for Sparse, see GH#24600
1470
+ # TODO: Why self.values and not values?
1471
+ mask = np .asarray (isna (self .values ))
1476
1472
result = nanpercentile (values , np .array (qs ) * 100 ,
1477
- axis = axis , na_value = self ._na_value ,
1473
+ axis = axis , na_value = self .fill_value ,
1478
1474
mask = mask , ndim = self .ndim ,
1479
1475
interpolation = interpolation )
1480
1476
@@ -1490,8 +1486,6 @@ def quantile(self, qs, interpolation='linear', axis=0):
1490
1486
1491
1487
ndim = getattr (result , 'ndim' , None ) or 0
1492
1488
result = self ._try_coerce_result (result )
1493
- if lib .is_scalar (result ):
1494
- return self .make_block_scalar (result )
1495
1489
return make_block (result ,
1496
1490
placement = np .arange (len (result )),
1497
1491
ndim = ndim )
@@ -1534,29 +1528,6 @@ def _replace_coerce(self, to_replace, value, inplace=True, regex=False,
1534
1528
return self
1535
1529
1536
1530
1537
- class ScalarBlock (Block ):
1538
- """
1539
- a scalar compat Block
1540
- """
1541
- __slots__ = ['_mgr_locs' , 'values' , 'ndim' ]
1542
-
1543
- def __init__ (self , values ):
1544
- self .ndim = 0
1545
- self .mgr_locs = [0 ]
1546
- self .values = values
1547
-
1548
- @property
1549
- def dtype (self ):
1550
- return type (self .values )
1551
-
1552
- @property
1553
- def shape (self ):
1554
- return tuple ([0 ])
1555
-
1556
- def __len__ (self ):
1557
- return 0
1558
-
1559
-
1560
1531
class NonConsolidatableMixIn (object ):
1561
1532
""" hold methods for the nonconsolidatable blocks """
1562
1533
_can_consolidate = False
@@ -2675,7 +2646,7 @@ def convert(self, *args, **kwargs):
2675
2646
2676
2647
if args :
2677
2648
raise NotImplementedError
2678
- by_item = True if 'by_item' not in kwargs else kwargs [ 'by_item' ]
2649
+ by_item = kwargs . get ( 'by_item' , True )
2679
2650
2680
2651
new_inputs = ['coerce' , 'datetime' , 'numeric' , 'timedelta' ]
2681
2652
new_style = False
0 commit comments