-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Labels
IndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesInternalsRelated to non-user accessible pandas implementationRelated to non-user accessible pandas implementation
Milestone
Description
https://github.com/pandas-dev/pandas/blob/master/pandas/core/internals.py#L4447
SingleBlockManager.reindex has only code code branch hit in test coverage, immediately returns self
. This is good because I think if it went further than that it would likely raise one of several errors.
The end of the method:
if self._block.is_sparse:
make_block = self._block.make_block_same_class
block = make_block(new_values, copy=copy,
placement=slice(0, len(new_axis)))
mgr = SingleBlockManager(block, new_axis)
mgr._consolidate_inplace()
return mgr
In the case where not self._block.is_sparse
, then I'm pretty sure the author intended for make_block
to point at the module-level make_block
function. But instead it would raise an UnboundLocalError
:
ser = pd.Series([1, 2, 3])
idx = ser.index * 2
>>> ser._data.reindex(idx)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas/core/internals.py", line 4518, in reindex
block = make_block(new_values, copy=copy,
UnboundLocalError: local variable 'make_block' referenced before assignment
Moreover, the call to make_block
passes a copy
kwarg, which is not accepted by the module-level function.
So my hope is that it can be confirmed that this method is no longer needed and can removed.
Metadata
Metadata
Assignees
Labels
IndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesInternalsRelated to non-user accessible pandas implementationRelated to non-user accessible pandas implementation