Skip to content

Commit cee2fc1

Browse files
committed
fix Timestamp.resolution pandas-dev#21336
1 parent 4cc77f7 commit cee2fc1

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

doc/source/whatsnew/v0.24.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ Datetimelike
301301
^^^^^^^^^^^^
302302

303303
- Fixed bug where two :class:`DateOffset` objects with different ``normalize`` attributes could evaluate as equal (:issue:`21404`)
304+
- Fixed bug where :meth:`Timestamp.resolution` incorrectly returned 1-microsecond ``timedelta`` instead of 1-nanosecond :class:`Timedelta` (:issue:`21336`,:issue:`21365`)
304305

305306
Timedelta
306307
^^^^^^^^^

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,15 @@ cdef class _Timestamp(datetime):
407407
def asm8(self):
408408
return np.datetime64(self.value, 'ns')
409409

410+
@property
411+
def resolution(self):
412+
"""
413+
Return resolution describing the smallest difference between two
414+
times that can be represented by Timestamp object_state
415+
"""
416+
# GH#21336, GH#21365
417+
return Timedelta(nanoseconds=1)
418+
410419
def timestamp(self):
411420
"""Return POSIX timestamp as float."""
412421
# py27 compat, see GH#17329

pandas/tests/scalar/timestamp/test_timestamp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ def test_woy_boundary(self):
172172
2005, 1, 1), (2005, 1, 2)]])
173173
assert (result == [52, 52, 53, 53]).all()
174174

175+
def test_resolution(self):
176+
# GH#21336, GH#21365
177+
dt = Timestamp('2100-01-01 00:00:00')
178+
assert dt.resolution == Timedelta(nanoseconds=1)
179+
175180

176181
class TestTimestampConstructors(object):
177182

0 commit comments

Comments
 (0)