@@ -325,16 +325,15 @@ def dtype(self):
325
325
def merge (self , other ):
326
326
return _merge_blocks ([self , other ])
327
327
328
- def concat_same_type (self , to_concat , placement = None ):
328
+ def concat_same_type (self , to_concat ):
329
329
"""
330
330
Concatenate list of single blocks of the same type.
331
331
"""
332
332
values = self ._concatenator (
333
333
[blk .values for blk in to_concat ], axis = self .ndim - 1
334
334
)
335
- return self .make_block_same_class (
336
- values , placement = placement or slice (0 , len (values ), 1 )
337
- )
335
+ placement = self .mgr_locs if self .ndim == 2 else slice (len (values ))
336
+ return self .make_block_same_class (values , placement = placement )
338
337
339
338
def iget (self , i ):
340
339
return self .values [i ]
@@ -1783,13 +1782,13 @@ def _slice(self, slicer):
1783
1782
1784
1783
return self .values [slicer ]
1785
1784
1786
- def concat_same_type (self , to_concat , placement = None ):
1785
+ def concat_same_type (self , to_concat ):
1787
1786
"""
1788
1787
Concatenate list of single blocks of the same type.
1789
1788
"""
1790
1789
values = self ._holder ._concat_same_type ([blk .values for blk in to_concat ])
1791
- placement = placement or slice (0 , len (values ), 1 )
1792
- return self .make_block_same_class (values , ndim = self . ndim , placement = placement )
1790
+ placement = self . mgr_locs if self . ndim == 2 else slice (len (values ))
1791
+ return self .make_block_same_class (values , placement = placement )
1793
1792
1794
1793
def fillna (self , value , limit = None , inplace = False , downcast = None ):
1795
1794
values = self .values if inplace else self .values .copy ()
@@ -2301,19 +2300,19 @@ def diff(self, n: int, axis: int = 0) -> List["Block"]:
2301
2300
new_values = new_values .astype ("timedelta64[ns]" )
2302
2301
return [TimeDeltaBlock (new_values , placement = self .mgr_locs .indexer )]
2303
2302
2304
- def concat_same_type (self , to_concat , placement = None ):
2303
+ def concat_same_type (self , to_concat ):
2305
2304
# need to handle concat([tz1, tz2]) here, since DatetimeArray
2306
2305
# only handles cases where all the tzs are the same.
2307
2306
# Instead of placing the condition here, it could also go into the
2308
2307
# is_uniform_join_units check, but I'm not sure what is better.
2309
2308
if len ({x .dtype for x in to_concat }) > 1 :
2310
2309
values = concat_datetime ([x .values for x in to_concat ])
2311
- placement = placement or slice (0 , len (values ), 1 )
2312
2310
2313
- if self .ndim > 1 :
2314
- values = np .atleast_2d (values )
2315
- return ObjectBlock (values , ndim = self .ndim , placement = placement )
2316
- return super ().concat_same_type (to_concat , placement )
2311
+ values = values .astype (object , copy = False )
2312
+ placement = self .mgr_locs if self .ndim == 2 else slice (len (values ))
2313
+
2314
+ return self .make_block (_block_shape (values , self .ndim ), placement = placement )
2315
+ return super ().concat_same_type (to_concat )
2317
2316
2318
2317
def fillna (self , value , limit = None , inplace = False , downcast = None ):
2319
2318
# We support filling a DatetimeTZ with a `value` whose timezone
@@ -2767,7 +2766,7 @@ def __init__(self, values, placement, ndim=None):
2767
2766
def _holder (self ):
2768
2767
return Categorical
2769
2768
2770
- def concat_same_type (self , to_concat , placement = None ):
2769
+ def concat_same_type (self , to_concat ):
2771
2770
"""
2772
2771
Concatenate list of single blocks of the same type.
2773
2772
@@ -2783,9 +2782,10 @@ def concat_same_type(self, to_concat, placement=None):
2783
2782
values = self ._concatenator (
2784
2783
[blk .values for blk in to_concat ], axis = self .ndim - 1
2785
2784
)
2785
+ placement = self .mgr_locs if self .ndim == 2 else slice (len (values ))
2786
2786
# not using self.make_block_same_class as values can be object dtype
2787
- return make_block (
2788
- values , placement = placement or slice ( 0 , len ( values ), 1 ), ndim = self .ndim
2787
+ return self . make_block (
2788
+ _block_shape ( values , ndim = self .ndim ), placement = placement
2789
2789
)
2790
2790
2791
2791
def replace (
0 commit comments