4848 is_timedelta64_dtype ,
4949 pandas_dtype ,
5050)
51- from pandas .core .dtypes .concat import concat_categorical , concat_datetime
5251from pandas .core .dtypes .dtypes import ExtensionDtype
5352from pandas .core .dtypes .generic import (
5453 ABCDataFrame ,
@@ -110,7 +109,6 @@ class Block(PandasObject):
110109 _can_consolidate = True
111110 _verify_integrity = True
112111 _validate_ndim = True
113- _concatenator = staticmethod (np .concatenate )
114112
115113 def __init__ (self , values , placement , ndim = None ):
116114 self .ndim = self ._check_ndim (values , ndim )
@@ -309,16 +307,6 @@ def shape(self):
309307 def dtype (self ):
310308 return self .values .dtype
311309
312- def concat_same_type (self , to_concat ):
313- """
314- Concatenate list of single blocks of the same type.
315- """
316- values = self ._concatenator (
317- [blk .values for blk in to_concat ], axis = self .ndim - 1
318- )
319- placement = self .mgr_locs if self .ndim == 2 else slice (len (values ))
320- return self .make_block_same_class (values , placement = placement )
321-
322310 def iget (self , i ):
323311 return self .values [i ]
324312
@@ -1770,14 +1758,6 @@ def _slice(self, slicer):
17701758
17711759 return self .values [slicer ]
17721760
1773- def concat_same_type (self , to_concat ):
1774- """
1775- Concatenate list of single blocks of the same type.
1776- """
1777- values = self ._holder ._concat_same_type ([blk .values for blk in to_concat ])
1778- placement = self .mgr_locs if self .ndim == 2 else slice (len (values ))
1779- return self .make_block_same_class (values , placement = placement )
1780-
17811761 def fillna (self , value , limit = None , inplace = False , downcast = None ):
17821762 values = self .values if inplace else self .values .copy ()
17831763 values = values .fillna (value = value , limit = limit )
@@ -2258,20 +2238,6 @@ def diff(self, n: int, axis: int = 0) -> List["Block"]:
22582238 new_values = new_values .astype ("timedelta64[ns]" )
22592239 return [TimeDeltaBlock (new_values , placement = self .mgr_locs .indexer )]
22602240
2261- def concat_same_type (self , to_concat ):
2262- # need to handle concat([tz1, tz2]) here, since DatetimeArray
2263- # only handles cases where all the tzs are the same.
2264- # Instead of placing the condition here, it could also go into the
2265- # is_uniform_join_units check, but I'm not sure what is better.
2266- if len ({x .dtype for x in to_concat }) > 1 :
2267- values = concat_datetime ([x .values for x in to_concat ])
2268-
2269- values = values .astype (object , copy = False )
2270- placement = self .mgr_locs if self .ndim == 2 else slice (len (values ))
2271-
2272- return self .make_block (values , placement = placement )
2273- return super ().concat_same_type (to_concat )
2274-
22752241 def fillna (self , value , limit = None , inplace = False , downcast = None ):
22762242 # We support filling a DatetimeTZ with a `value` whose timezone
22772243 # is different by coercing to object.
@@ -2642,7 +2608,6 @@ class CategoricalBlock(ExtensionBlock):
26422608 is_categorical = True
26432609 _verify_integrity = True
26442610 _can_hold_na = True
2645- _concatenator = staticmethod (concat_categorical )
26462611
26472612 should_store = Block .should_store
26482613
@@ -2656,26 +2621,6 @@ def __init__(self, values, placement, ndim=None):
26562621 def _holder (self ):
26572622 return Categorical
26582623
2659- def concat_same_type (self , to_concat ):
2660- """
2661- Concatenate list of single blocks of the same type.
2662-
2663- Note that this CategoricalBlock._concat_same_type *may* not
2664- return a CategoricalBlock. When the categories in `to_concat`
2665- differ, this will return an object ndarray.
2666-
2667- If / when we decide we don't like that behavior:
2668-
2669- 1. Change Categorical._concat_same_type to use union_categoricals
2670- 2. Delete this method.
2671- """
2672- values = self ._concatenator (
2673- [blk .values for blk in to_concat ], axis = self .ndim - 1
2674- )
2675- placement = self .mgr_locs if self .ndim == 2 else slice (len (values ))
2676- # not using self.make_block_same_class as values can be object dtype
2677- return self .make_block (values , placement = placement )
2678-
26792624 def replace (
26802625 self ,
26812626 to_replace ,
0 commit comments