@@ -1384,15 +1384,13 @@ def equals(self, other) -> bool:
1384
1384
return False
1385
1385
return array_equivalent (self .values , other .values )
1386
1386
1387
- def _unstack (self , unstacker , new_columns , fill_value , value_columns ):
1387
+ def _unstack (self , unstacker , fill_value , new_placement ):
1388
1388
"""
1389
1389
Return a list of unstacked blocks of self
1390
1390
1391
1391
Parameters
1392
1392
----------
1393
1393
unstacker : reshape._Unstacker
1394
- new_columns : Index
1395
- All columns of the unstacked BlockManager.
1396
1394
fill_value : int
1397
1395
Only used in ExtensionBlock._unstack
1398
1396
@@ -1403,17 +1401,17 @@ def _unstack(self, unstacker, new_columns, fill_value, value_columns):
1403
1401
mask : array_like of bool
1404
1402
The mask of columns of `blocks` we should keep.
1405
1403
"""
1406
- new_items = unstacker .get_new_columns (value_columns )
1407
- new_placement = new_columns .get_indexer (new_items )
1408
1404
new_values , mask = unstacker .get_new_values (
1409
1405
self .values .T , fill_value = fill_value
1410
1406
)
1411
1407
1412
1408
mask = mask .any (0 )
1409
+ # TODO: in all tests we have mask.all(); can we rely on that?
1410
+
1413
1411
new_values = new_values .T [mask ]
1414
1412
new_placement = new_placement [mask ]
1415
1413
1416
- blocks = [make_block (new_values , placement = new_placement )]
1414
+ blocks = [self . make_block_same_class (new_values , placement = new_placement )]
1417
1415
return blocks , mask
1418
1416
1419
1417
def quantile (self , qs , interpolation = "linear" , axis : int = 0 ):
@@ -1878,7 +1876,7 @@ def where(
1878
1876
1879
1877
return [self .make_block_same_class (result , placement = self .mgr_locs )]
1880
1878
1881
- def _unstack (self , unstacker , new_columns , fill_value , value_columns ):
1879
+ def _unstack (self , unstacker , fill_value , new_placement ):
1882
1880
# ExtensionArray-safe unstack.
1883
1881
# We override ObjectBlock._unstack, which unstacks directly on the
1884
1882
# values of the array. For EA-backed blocks, this would require
@@ -1888,10 +1886,9 @@ def _unstack(self, unstacker, new_columns, fill_value, value_columns):
1888
1886
n_rows = self .shape [- 1 ]
1889
1887
dummy_arr = np .arange (n_rows )
1890
1888
1891
- new_items = unstacker .get_new_columns (value_columns )
1892
- new_placement = new_columns .get_indexer (new_items )
1893
1889
new_values , mask = unstacker .get_new_values (dummy_arr , fill_value = - 1 )
1894
1890
mask = mask .any (0 )
1891
+ # TODO: in all tests we have mask.all(); can we rely on that?
1895
1892
1896
1893
blocks = [
1897
1894
self .make_block_same_class (
0 commit comments