Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Fix PR02 errors in Timedelta attributes (min, max, resolution) d… #60486

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1bd123a
DOC: Fix PR02 errors in Timedelta attributes (min, max, resolution) d…
brownl83 Dec 3, 2024
d7ba6ad
White space error
brownl83 Dec 3, 2024
5e9d8d3
White space error
brownl83 Dec 3, 2024
f086358
removed
brownl83 Dec 3, 2024
5c6878f
assigned new docstrings to address unknown parameter
brownl83 Dec 3, 2024
c26c504
that didn't work
brownl83 Dec 3, 2024
b04921d
added min, max, resolution as property
brownl83 Dec 3, 2024
3971071
fixed white space
brownl83 Dec 3, 2024
3500144
fixed double quote
brownl83 Dec 3, 2024
e5d29a4
defined them as class level attributes
brownl83 Dec 3, 2024
f382ef5
fix lint line space issue
brownl83 Dec 3, 2024
c7a8c8e
reverted back to old implmention to try again
brownl83 Dec 3, 2024
b6271bb
reverted back to old implmention to try again
brownl83 Dec 3, 2024
5c480ca
trying to override docstring to avoid unknown paramter error
brownl83 Dec 4, 2024
2ae8204
added back in remove timestamp code checks
brownl83 Dec 4, 2024
a4f6cbc
removed over ride doc
brownl83 Dec 4, 2024
958085c
fixed line to long
brownl83 Dec 4, 2024
0c401f1
removed min, max, res call
brownl83 Dec 4, 2024
d1b924a
added see also to min, max, resolution
brownl83 Dec 4, 2024
d7e169a
added alias in timedeltas.py
brownl83 Dec 4, 2024
f2ebb00
removed alias in timedeltas.py
brownl83 Dec 4, 2024
59785d7
moved attributes to cdef class _Timedelta
brownl83 Dec 4, 2024
5e0f541
trying again with different format
brownl83 Dec 4, 2024
8a60f00
moved attributes back to Timedelta, set as read only
brownl83 Dec 4, 2024
2140fc1
added inline docstring to enforce that min,max,reso are constants not…
brownl83 Dec 4, 2024
45de848
fix ponitless string error
brownl83 Dec 4, 2024
0749625
white space
brownl83 Dec 4, 2024
4d0ce2a
explicityly setting the _doc_ attribute
brownl83 Dec 4, 2024
27efa51
assign descriptors within the class
brownl83 Dec 4, 2024
2f4d35b
assign descriptors within the class
brownl83 Dec 4, 2024
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
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
28 changes: 28 additions & 0 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
Loading