@@ -325,16 +325,15 @@ def dtype(self):
325325 def merge (self , other ):
326326 return _merge_blocks ([self , other ])
327327
328- def concat_same_type (self , to_concat , placement = None ):
328+ def concat_same_type (self , to_concat ):
329329 """
330330 Concatenate list of single blocks of the same type.
331331 """
332332 values = self ._concatenator (
333333 [blk .values for blk in to_concat ], axis = self .ndim - 1
334334 )
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 )
338337
339338 def iget (self , i ):
340339 return self .values [i ]
@@ -1783,13 +1782,13 @@ def _slice(self, slicer):
17831782
17841783 return self .values [slicer ]
17851784
1786- def concat_same_type (self , to_concat , placement = None ):
1785+ def concat_same_type (self , to_concat ):
17871786 """
17881787 Concatenate list of single blocks of the same type.
17891788 """
17901789 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 )
17931792
17941793 def fillna (self , value , limit = None , inplace = False , downcast = None ):
17951794 values = self .values if inplace else self .values .copy ()
@@ -2301,19 +2300,19 @@ def diff(self, n: int, axis: int = 0) -> List["Block"]:
23012300 new_values = new_values .astype ("timedelta64[ns]" )
23022301 return [TimeDeltaBlock (new_values , placement = self .mgr_locs .indexer )]
23032302
2304- def concat_same_type (self , to_concat , placement = None ):
2303+ def concat_same_type (self , to_concat ):
23052304 # need to handle concat([tz1, tz2]) here, since DatetimeArray
23062305 # only handles cases where all the tzs are the same.
23072306 # Instead of placing the condition here, it could also go into the
23082307 # is_uniform_join_units check, but I'm not sure what is better.
23092308 if len ({x .dtype for x in to_concat }) > 1 :
23102309 values = concat_datetime ([x .values for x in to_concat ])
2311- placement = placement or slice (0 , len (values ), 1 )
23122310
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 )
23172316
23182317 def fillna (self , value , limit = None , inplace = False , downcast = None ):
23192318 # We support filling a DatetimeTZ with a `value` whose timezone
@@ -2767,7 +2766,7 @@ def __init__(self, values, placement, ndim=None):
27672766 def _holder (self ):
27682767 return Categorical
27692768
2770- def concat_same_type (self , to_concat , placement = None ):
2769+ def concat_same_type (self , to_concat ):
27712770 """
27722771 Concatenate list of single blocks of the same type.
27732772
@@ -2783,9 +2782,10 @@ def concat_same_type(self, to_concat, placement=None):
27832782 values = self ._concatenator (
27842783 [blk .values for blk in to_concat ], axis = self .ndim - 1
27852784 )
2785+ placement = self .mgr_locs if self .ndim == 2 else slice (len (values ))
27862786 # 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
27892789 )
27902790
27912791 def replace (
0 commit comments