@@ -451,9 +451,9 @@ def to_native_types(self, slicer=None, na_rep='', **kwargs):
451451 values [mask ] = na_rep
452452 return values .tolist ()
453453
454- def _validate_merge (self , blocks ):
455- """ validate that we can merge these blocks """
456- return True
454+ def _concat_blocks (self , blocks , values ):
455+ """ return the block concatenation """
456+ return self . _holder ( values [ 0 ])
457457
458458 # block actions ####
459459 def copy (self , deep = True ):
@@ -1639,15 +1639,19 @@ def _astype(self, dtype, copy=False, raise_on_error=True, values=None,
16391639 ndim = self .ndim ,
16401640 placement = self .mgr_locs )
16411641
1642- def _validate_merge (self , blocks ):
1643- """ validate that we can merge these blocks """
1642+ def _concat_blocks (self , blocks , values ):
1643+ """
1644+ validate that we can merge these blocks
1645+
1646+ return the block concatenation
1647+ """
16441648
16451649 levels = self .values .levels
16461650 for b in blocks :
16471651 if not levels .equals (b .values .levels ):
16481652 raise ValueError ("incompatible levels in categorical block merge" )
16491653
1650- return True
1654+ return self . _holder ( values [ 0 ], levels = levels )
16511655
16521656 def to_native_types (self , slicer = None , na_rep = '' , ** kwargs ):
16531657 """ convert to our native types format, slicing if desired """
@@ -4026,17 +4030,11 @@ def concatenate_join_units(join_units, concat_axis, copy):
40264030 else :
40274031 concat_values = com ._concat_compat (to_concat , axis = concat_axis )
40284032
4029- # FIXME: optimization potential: if len(join_units) == 1, single join unit
4030- # is densified and sparsified back.
40314033 if any (unit .needs_block_conversion for unit in join_units ):
40324034
40334035 # need to ask the join unit block to convert to the underlying repr for us
40344036 blocks = [ unit .block for unit in join_units if unit .block is not None ]
4035-
4036- # may need to validate this combination
4037- blocks [0 ]._validate_merge (blocks )
4038-
4039- return blocks [0 ]._holder (concat_values [0 ])
4037+ return blocks [0 ]._concat_blocks (blocks , concat_values )
40404038 else :
40414039 return concat_values
40424040
0 commit comments