-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
CleanInternalsRelated to non-user accessible pandas implementationRelated to non-user accessible pandas implementationRefactorInternal refactoring of codeInternal refactoring of code
Milestone
Description
Splitting off from #19268 (which is starting to give me unicorns fairly often)
After that, all blocks eventually end up calling Block.__init__
(aside from ScalarBlock
, which we'll ignore).
Most of the subclasses init methods are
- maybe coerce values to the expected dtype
call super().__init__
It'd be nice to put 1 into favor of a _maybe_coerce_values
method defined by each block, and remove all the subclasses init methods.
The one sticking point will be DatetimeTZBlock.__init__
, which accepts a dtype
parameter that no other block does.
pandas/pandas/core/internals.py
Lines 2582 to 2590 in 35812ea
def __init__(self, values, placement, ndim=2, dtype=None): | |
if not isinstance(values, self._holder): | |
values = self._holder(values) | |
if dtype is not None: | |
if isinstance(dtype, compat.string_types): | |
dtype = DatetimeTZDtype.construct_from_string(dtype) | |
values = values._shallow_copy(tz=dtype.tz) |
We could maybe push that onto the callers, and then clean things up.
Metadata
Metadata
Assignees
Labels
CleanInternalsRelated to non-user accessible pandas implementationRelated to non-user accessible pandas implementationRefactorInternal refactoring of codeInternal refactoring of code