@@ -1285,6 +1285,10 @@ def _unstack(self, unstacker, fill_value, new_placement, allow_fill: bool):
1285
1285
mask = mask .any (0 )
1286
1286
# TODO: in all tests we have mask.all(); can we rely on that?
1287
1287
1288
+ # Note: these next two lines ensure that
1289
+ # mask.sum() == sum(len(nb.mgr_locs) for nb in blocks)
1290
+ # which the calling function needs in order to pass verify_integrity=False
1291
+ # to the BlockManager constructor
1288
1292
new_values = new_values .T [mask ]
1289
1293
new_placement = new_placement [mask ]
1290
1294
@@ -1656,13 +1660,21 @@ def _unstack(self, unstacker, fill_value, new_placement, allow_fill: bool):
1656
1660
mask = mask .any (0 )
1657
1661
# TODO: in all tests we have mask.all(); can we rely on that?
1658
1662
1663
+ # Note: these next two lines ensure that
1664
+ # mask.sum() == sum(len(nb.mgr_locs) for nb in blocks)
1665
+ # which the calling function needs in order to pass verify_integrity=False
1666
+ # to the BlockManager constructor
1667
+ new_values = new_values .T [mask ]
1668
+ new_placement = new_placement [mask ]
1669
+
1659
1670
blocks = [
1660
1671
# TODO: could cast to object depending on fill_value?
1661
- self . make_block_same_class (
1672
+ type ( self ) (
1662
1673
self .values .take (indices , allow_fill = allow_fill , fill_value = fill_value ),
1663
1674
BlockPlacement (place ),
1675
+ ndim = 2 ,
1664
1676
)
1665
- for indices , place in zip (new_values . T , new_placement )
1677
+ for indices , place in zip (new_values , new_placement )
1666
1678
]
1667
1679
return blocks , mask
1668
1680
0 commit comments