diff --git a/ci/code_checks.sh b/ci/code_checks.sh index f23481b3da3a2..9b464714cdf56 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -73,9 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Period.freq GL08" \ -i "pandas.Period.ordinal GL08" \ -i "pandas.RangeIndex.from_range PR01,SA01" \ - -i "pandas.Timedelta.max PR02" \ - -i "pandas.Timedelta.min PR02" \ - -i "pandas.Timedelta.resolution PR02" \ -i "pandas.Timestamp.max PR02" \ -i "pandas.Timestamp.min PR02" \ -i "pandas.Timestamp.resolution PR02" \ diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index e320aca04683c..2bfed0c608ff4 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1894,6 +1894,17 @@ class Timedelta(_Timedelta): Values for construction in compat with datetime.timedelta. Numpy ints and floats will be coerced to python ints and floats. + Attributes + ---------- + min : Timedelta, readonly + The minimum representable `Timedelta`, corresponding to the smallest + duration supported. + max : Timedelta, readonly + The maximum representable `Timedelta`, corresponding to the largest + duration supported. + resolution : Timedelta, readonly + The smallest possible difference between non-equal `Timedelta` objects. + See Also -------- Timestamp : Represents a single timestamp in time. @@ -1928,6 +1939,19 @@ class Timedelta(_Timedelta): Timedelta('1 days 00:00:00') We see that either way we get the same result + + Accessing the smallest and largest Timedelta values: + + >>> pd.Timedelta.min + Timedelta('-106752 days +00:12:43.145224193') + + >>> pd.Timedelta.max + Timedelta('106751 days 23:47:16.854775807') + + Checking the resolution of a Timedelta object: + + >>> pd.Timedelta.resolution + Timedelta('0 days 00:00:00.000000001') """ _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds", @@ -2077,6 +2101,10 @@ class Timedelta(_Timedelta): return _timedelta_from_value_and_reso(cls, value, NPY_FR_ns) + min = MinMaxReso("min") + max = MinMaxReso("max") + resolution = MinMaxReso("resolution") + def __setstate__(self, state): if len(state) == 1: # older pickle, only supported nanosecond