Skip to content
Closed
Changes from 3 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: 4 additions & 2 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ def maybe_box(indexer, values, obj, key):
def maybe_box_datetimelike(value):
# turn a datetime like into a Timestamp/timedelta as needed

if isinstance(value, (np.datetime64, datetime)):
if isinstance(value, (np.datetime64, datetime)) \
and not isinstance(value, tslibs.Timestamp):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also exclude NaT

value = tslibs.Timestamp(value)
elif isinstance(value, (np.timedelta64, timedelta)):
elif isinstance(value, (np.timedelta64, timedelta)) \
and not isinstance(value, tslibs.Timedelta):
value = tslibs.Timedelta(value)

return value
Expand Down