8000 CLN: move maybe_casted_values from pandas/core/frame.py to pandas/core/dtype/cast.py by arw2019 · Pull Request #36985 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

CLN: move maybe_casted_values from pandas/core/frame.py to pandas/core/dtype/cast.py #36985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 10, 2020
Prev Previous commit
Next Next commit
feedback: replace issubclass(., DatetimeLikeArray)
  • Loading branch information
arw2019 committed Oct 10, 2020
commit 2b6e15f062dbf71ffee4053c845b2aa7b18a8638
11 changes: 3 additions & 8 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
is_timedelta64_dtype,
is_timedelta64_ns_dtype,
is_unsigned_integer_dtype,
needs_i8_conversion,
pandas_dtype,
)
from pandas.core.dtypes.dtypes import (
Expand Down Expand Up @@ -487,19 +488,13 @@ def maybe_casted_values(index, codes=None):
values_type = type(values)
values_dtype = values.dtype

from pandas.core.arrays.datetimelike import (
DatetimeLikeArrayMixin as DatetimeLikeArray,
)

if issubclass(values_type, DatetimeLikeArray):
if needs_i8_conversion(values.dtype) and isinstance(values, ExtensionArray):
values = values._data # TODO: can we de-kludge yet?

if mask.any():
values, _ = maybe_upcast_putmask(values, mask, np.nan)

if not issubclass(values_type, DatetimeLikeArray):
pass
else:
if needs_i8_conversion(values.dtype) and isinstance(values, ExtensionArray):
values = values_type(values, dtype=values_dtype)

return values
Expand Down
0