48
48
is_timedelta64_dtype ,
49
49
pandas_dtype ,
50
50
)
51
- from pandas .core .dtypes .concat import concat_categorical , concat_datetime
52
51
from pandas .core .dtypes .dtypes import ExtensionDtype
53
52
from pandas .core .dtypes .generic import (
54
53
ABCDataFrame ,
@@ -110,7 +109,6 @@ class Block(PandasObject):
110
109
_can_consolidate = True
111
110
_verify_integrity = True
112
111
_validate_ndim = True
113
- _concatenator = staticmethod (np .concatenate )
114
112
115
113
def __init__ (self , values , placement , ndim = None ):
116
114
self .ndim = self ._check_ndim (values , ndim )
@@ -309,16 +307,6 @@ def shape(self):
309
307
def dtype (self ):
310
308
return self .values .dtype
311
309
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
-
322
310
def iget (self , i ):
323
311
return self .values [i ]
324
312
@@ -1770,14 +1758,6 @@ def _slice(self, slicer):
1770
1758
1771
1759
return self .values [slicer ]
1772
1760
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
-
1781
1761
def fillna (self , value , limit = None , inplace = False , downcast = None ):
1782
1762
values = self .values if inplace else self .values .copy ()
1783
1763
values = values .fillna (value = value , limit = limit )
@@ -2258,20 +2238,6 @@ def diff(self, n: int, axis: int = 0) -> List["Block"]:
2258
2238
new_values = new_values .astype ("timedelta64[ns]" )
2259
2239
return [TimeDeltaBlock (new_values , placement = self .mgr_locs .indexer )]
2260
2240
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
-
2275
2241
def fillna (self , value , limit = None , inplace = False , downcast = None ):
2276
2242
# We support filling a DatetimeTZ with a `value` whose timezone
2277
2243
# is different by coercing to object.
@@ -2642,7 +2608,6 @@ class CategoricalBlock(ExtensionBlock):
2642
2608
is_categorical = True
2643
2609
_verify_integrity = True
2644
2610
_can_hold_na = True
2645
- _concatenator = staticmethod (concat_categorical )
2646
2611
2647
2612
should_store = Block .should_store
2648
2613
@@ -2656,26 +2621,6 @@ def __init__(self, values, placement, ndim=None):
2656
2621
def _holder (self ):
2657
2622
return Categorical
2658
2623
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
-
2679
2624
def replace (
2680
2625
self ,
2681
2626
to_replace ,
0 commit comments