Skip to content

Commit b04921d

Browse files
committed
added min, max, resolution as property
1 parent c26c504 commit b04921d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,42 @@ class Timedelta(_Timedelta):
19451945
_req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds",
19461946
"milliseconds", "microseconds", "nanoseconds"}
19471947

1948+
@property
1949+
def min(self):
1950+
"""
1951+
The minimum representable Timedelta.
1952+
1953+
Returns
1954+
-------
1955+
Timedelta
1956+
The minimum duration supported by Timedelta.
1957+
"""
1958+
return Timedelta(np.timedelta64(np.iinfo(np.int64).min + 1, 'ns'))
1959+
1960+
@property
1961+
def max(self):
1962+
"""
1963+
The maximum representable Timedelta.
1964+
1965+
Returns
1966+
-------
1967+
Timedelta
1968+
The maximum duration supported by Timedelta.
1969+
"""
1970+
return Timedelta(np.timedelta64(np.iinfo(np.int64).max, 'ns'))
1971+
1972+
@property
1973+
def resolution(self):
1974+
"""
1975+
The smallest possible difference between non-equal Timedelta objects.
1976+
1977+
Returns
1978+
-------
1979+
Timedelta
1980+
The resolution of Timedelta, i.e. Timedelta(nanoseconds=1).
1981+
"""
1982+
return Timedelta(1, unit='ns')
1983+
19481984
def __new__(cls, object value=_no_input, unit=None, **kwargs):
19491985
if value is _no_input:
19501986
if not len(kwargs):

0 commit comments

Comments
 (0)