Skip to content

Commit 8aad74c

Browse files
committed
Extend docstrings
1 parent 0acb6f3 commit 8aad74c

File tree

1 file changed

+44
-9
lines changed

1 file changed

+44
-9
lines changed

pandas/core/internals.py

+44-9
Original file line numberDiff line numberDiff line change
@@ -1484,9 +1484,24 @@ def equals(self, other):
14841484
return False
14851485
return array_equivalent(self.values, other.values)
14861486

1487-
def _unstack(self, unstacker_t, new_columns):
1488-
"""Return a list of unstacked blocks of self"""
1489-
unstacker = unstacker_t(self.values.T)
1487+
def _unstack(self, unstacker_func, new_columns):
1488+
"""Return a list of unstacked blocks of self
1489+
1490+
Parameters
1491+
----------
1492+
unstacker_func : callable
1493+
Partially applied unstacker.
1494+
new_columns : Index
1495+
All columns of the unstacked BlockManager.
1496+
1497+
Returns
1498+
-------
1499+
blocks : list of Block
1500+
New blocks of unstacked values.
1501+
mask : array_like of bool
1502+
The mask of columns of `blocks` we should keep.
1503+
"""
1504+
unstacker = unstacker_func(self.values.T)
14901505
new_items = unstacker.get_new_columns()
14911506
new_placement = new_columns.get_indexer(new_items)
14921507
new_values, mask = unstacker.get_new_values()
@@ -1726,10 +1741,26 @@ def _slice(self, slicer):
17261741
def _try_cast_result(self, result, dtype=None):
17271742
return result
17281743

1729-
def _unstack(self, unstacker_t, new_columns):
1744+
def _unstack(self, unstacker_func, new_columns):
1745+
"""Return a list of unstacked blocks of self
1746+
1747+
Parameters
1748+
----------
1749+
unstacker_func : callable
1750+
Partially applied unstacker.
1751+
new_columns : Index
1752+
All columns of the unstacked BlockManager.
1753+
1754+
Returns
1755+
-------
1756+
blocks : list of Block
1757+
New blocks of unstacked values.
1758+
mask : array_like of bool
1759+
The mask of columns of `blocks` we should keep.
1760+
"""
17301761
# NonConsolidatable blocks can have a single item only, so we return
17311762
# one block per item
1732-
unstacker = unstacker_t(self.values.T)
1763+
unstacker = unstacker_func(self.values.T)
17331764
new_items = unstacker.get_new_columns()
17341765
new_placement = new_columns.get_indexer(new_items)
17351766
new_values, mask = unstacker.get_new_values()
@@ -4197,23 +4228,27 @@ def canonicalize(block):
41974228
return all(block.equals(oblock)
41984229
for block, oblock in zip(self_blocks, other_blocks))
41994230

4200-
def unstack(self, unstacker_t):
4231+
def unstack(self, unstacker_func):
42014232
"""Return a blockmanager with all blocks unstacked.
42024233
42034234
Parameters
42044235
----------
4205-
unstacker_t : type
4236+
unstacker_func : callable
42064237
A (partially-applied) ``pd.core.reshape._Unstacker`` class.
4238+
4239+
Returns
4240+
-------
4241+
unstacked : BlockManager
42074242
"""
4208-
dummy = unstacker_t(np.empty((0, 0)), value_columns=self.items)
4243+
dummy = unstacker_func(np.empty((0, 0)), value_columns=self.items)
42094244
new_columns = dummy.get_new_columns()
42104245
new_index = dummy.get_new_index()
42114246
new_blocks = []
42124247
columns_mask = []
42134248

42144249
for blk in self.blocks:
42154250
blocks, mask = blk._unstack(
4216-
partial(unstacker_t,
4251+
partial(unstacker_func,
42174252
value_columns=self.items[blk.mgr_locs.indexer]),
42184253
new_columns)
42194254

0 commit comments

Comments
 (0)