Skip to content
Merged
Changes from 1 commit
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
13 changes: 4 additions & 9 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1157,18 +1157,13 @@ cdef class _Timestamp(datetime):

If warn=True, issue a warning if nanoseconds is nonzero.
"""
cdef:
pandas_datetimestruct dts
_TSObject ts

if self.nanosecond != 0 and warn:
warnings.warn("Discarding nonzero nanoseconds in conversion",
UserWarning, stacklevel=2)
ts = convert_to_tsobject(self, self.tzinfo, None, 0, 0)
dts = ts.dts
return datetime(dts.year, dts.month, dts.day,
dts.hour, dts.min, dts.sec,
dts.us, ts.tzinfo)

return datetime(self.year, self.month, self.day,
self.hour, self.minute, self.second,
Copy link
Contributor

Choose a reason for hiding this comment

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

indendation

self.microsecond, self.tzinfo)

cpdef to_datetime64(self):
""" Returns a numpy.datetime64 object with 'ns' precision """
Expand Down