@@ -451,9 +451,9 @@ def to_native_types(self, slicer=None, na_rep='', **kwargs):
451
451
values [mask ] = na_rep
452
452
return values .tolist ()
453
453
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 ])
457
457
458
458
# block actions ####
459
459
def copy (self , deep = True ):
@@ -1639,15 +1639,19 @@ def _astype(self, dtype, copy=False, raise_on_error=True, values=None,
1639
1639
ndim = self .ndim ,
1640
1640
placement = self .mgr_locs )
1641
1641
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
+ """
1644
1648
1645
1649
levels = self .values .levels
1646
1650
for b in blocks :
1647
1651
if not levels .equals (b .values .levels ):
1648
1652
raise ValueError ("incompatible levels in categorical block merge" )
1649
1653
1650
- return True
1654
+ return self . _holder ( values [ 0 ], levels = levels )
1651
1655
1652
1656
def to_native_types (self , slicer = None , na_rep = '' , ** kwargs ):
1653
1657
""" convert to our native types format, slicing if desired """
@@ -4026,17 +4030,11 @@ def concatenate_join_units(join_units, concat_axis, copy):
4026
4030
else :
4027
4031
concat_values = com ._concat_compat (to_concat , axis = concat_axis )
4028
4032
4029
- # FIXME: optimization potential: if len(join_units) == 1, single join unit
4030
- # is densified and sparsified back.
4031
4033
if any (unit .needs_block_conversion for unit in join_units ):
4032
4034
4033
4035
# need to ask the join unit block to convert to the underlying repr for us
4034
4036
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 )
4040
4038
else :
4041
4039
return concat_values
4042
4040
0 commit comments