Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,11 @@ class TimeDeltaBlock(DatetimeLikeBlockMixin, IntBlock):

def _maybe_coerce_values(self, values):
if values.dtype != TD64NS_DTYPE:
# e.g. non-nano or int64
# non-nano we will convert to nano
if values.dtype.kind != "m":
# caller is responsible for ensuring timedelta64 dtype
raise TypeError(values.dtype) # pragma: no cover

values = TimedeltaArray._from_sequence(values)._data
if isinstance(values, TimedeltaArray):
values = values._data
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,9 @@ def interpolate_2d(
if ndim == 1:
result = result[0]

if orig_values.dtype.kind == "M":
# convert float back to datetime64
result = result.astype(orig_values.dtype)
if orig_values.dtype.kind in ["m", "M"]:
# convert float back to datetime64/timedelta64
result = result.view(orig_values.dtype)

return result

Expand Down