Skip to content

Commit 331bc5f

Browse files
committed
Extend docstrings
1 parent 82edc0f commit 331bc5f

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
@@ -1468,9 +1468,24 @@ def equals(self, other):
14681468
return False
14691469
return array_equivalent(self.values, other.values)
14701470

1471-
def _unstack(self, unstacker_t, new_columns):
1472-
"""Return a list of unstacked blocks of self"""
1473-
unstacker = unstacker_t(self.values.T)
1471+
def _unstack(self, unstacker_func, new_columns):
1472+
"""Return a list of unstacked blocks of self
1473+
1474+
Parameters
1475+
----------
1476+
unstacker_func : callable
1477+
Partially applied unstacker.
1478+
new_columns : Index
1479+
All columns of the unstacked BlockManager.
1480+
1481+
Returns
1482+
-------
1483+
blocks : list of Block
1484+
New blocks of unstacked values.
1485+
mask : array_like of bool
1486+
The mask of columns of `blocks` we should keep.
1487+
"""
1488+
unstacker = unstacker_func(self.values.T)
14741489
new_items = unstacker.get_new_columns()
14751490
new_placement = new_columns.get_indexer(new_items)
14761491
new_values, mask = unstacker.get_new_values()
@@ -1718,10 +1733,26 @@ def _slice(self, slicer):
17181733
def _try_cast_result(self, result, dtype=None):
17191734
return result
17201735

1721-
def _unstack(self, unstacker_t, new_columns):
1736+
def _unstack(self, unstacker_func, new_columns):
1737+
"""Return a list of unstacked blocks of self
1738+
1739+
Parameters
1740+
----------
1741+
unstacker_func : callable
1742+
Partially applied unstacker.
1743+
new_columns : Index
1744+
All columns of the unstacked BlockManager.
1745+
1746+
Returns
1747+
-------
1748+
blocks : list of Block
1749+
New blocks of unstacked values.
1750+
mask : array_like of bool
1751+
The mask of columns of `blocks` we should keep.
1752+
"""
17221753
# NonConsolidatable blocks can have a single item only, so we return
17231754
# one block per item
1724-
unstacker = unstacker_t(self.values.T)
1755+
unstacker = unstacker_func(self.values.T)
17251756
new_items = unstacker.get_new_columns()
17261757
new_placement = new_columns.get_indexer(new_items)
17271758
new_values, mask = unstacker.get_new_values()
@@ -4189,23 +4220,27 @@ def canonicalize(block):
41894220
return all(block.equals(oblock)
41904221
for block, oblock in zip(self_blocks, other_blocks))
41914222

4192-
def unstack(self, unstacker_t):
4223+
def unstack(self, unstacker_func):
41934224
"""Return a blockmanager with all blocks unstacked.
41944225
41954226
Parameters
41964227
----------
4197-
unstacker_t : type
4228+
unstacker_func : callable
41984229
A (partially-applied) ``pd.core.reshape._Unstacker`` class.
4230+
4231+
Returns
4232+
-------
4233+
unstacked : BlockManager
41994234
"""
4200-
dummy = unstacker_t(np.empty((0, 0)), value_columns=self.items)
4235+
dummy = unstacker_func(np.empty((0, 0)), value_columns=self.items)
42014236
new_columns = dummy.get_new_columns()
42024237
new_index = dummy.get_new_index()
42034238
new_blocks = []
42044239
columns_mask = []
42054240

42064241
for blk in self.blocks:
42074242
blocks, mask = blk._unstack(
4208-
partial(unstacker_t,
4243+
partial(unstacker_func,
42094244
value_columns=self.items[blk.mgr_locs.indexer]),
42104245
new_columns)
42114246

0 commit comments

Comments
 (0)