@@ -510,8 +510,19 @@ def split_and_operate(self, func, *args, **kwargs) -> List[Block]:
510
510
res_blocks .extend (rbs )
511
511
return res_blocks
512
512
513
+ @final
513
514
def _maybe_downcast (self , blocks : List [Block ], downcast = None ) -> List [Block ]:
514
515
516
+ if self .dtype == _dtype_obj :
517
+ # TODO: why is behavior different for object dtype?
518
+ if downcast is not None :
519
+ return blocks
520
+
521
+ # split and convert the blocks
522
+ return extend_blocks (
523
+ [blk .convert (datetime = True , numeric = False ) for blk in blocks ]
524
+ )
525
+
515
526
# no need to downcast our float
516
527
# unless indicated
517
528
if downcast is None and self .dtype .kind in ["f" , "m" , "M" ]:
@@ -520,6 +531,7 @@ def _maybe_downcast(self, blocks: List[Block], downcast=None) -> List[Block]:
520
531
521
532
return extend_blocks ([b .downcast (downcast ) for b in blocks ])
522
533
534
+ @final
523
535
def downcast (self , dtypes = None ) -> List [Block ]:
524
536
""" try to downcast each item to the dict of dtypes if present """
525
537
# turn it off completely
@@ -1375,6 +1387,7 @@ def _unstack(self, unstacker, fill_value, new_placement):
1375
1387
blocks = [new_block (new_values , placement = new_placement , ndim = 2 )]
1376
1388
return blocks , mask
1377
1389
1390
+ @final
1378
1391
def quantile (
1379
1392
self , qs : Float64Index , interpolation = "linear" , axis : int = 0
1380
1393
) -> Block :
@@ -1952,14 +1965,6 @@ def convert(
1952
1965
res_values = ensure_block_shape (res_values , self .ndim )
1953
1966
return [self .make_block (res_values )]
1954
1967
1955
- def _maybe_downcast (self , blocks : List [Block ], downcast = None ) -> List [Block ]:
1956
-
1957
- if downcast is not None :
1958
- return blocks
1959
-
1960
- # split and convert the blocks
1961
- return extend_blocks ([b .convert (datetime = True , numeric = False ) for b in blocks ])
1962
-
1963
1968
def _can_hold_element (self , element : Any ) -> bool :
1964
1969
return True
1965
1970
0 commit comments