Skip to content

Commit 1bcdfd0

Browse files
DOC: Added docstrings to min, max, and reso (#61238)
Added docstrings to min, max, and reso Co-authored-by: John Hendricks <[email protected]>
1 parent 9df1430 commit 1bcdfd0

File tree

2 files changed

+77
-10
lines changed

2 files changed

+77
-10
lines changed

ci/code_checks.sh

-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
7373
-i "pandas.Period.freq GL08" \
7474
-i "pandas.Period.ordinal GL08" \
75-
-i "pandas.Timestamp.max PR02" \
76-
-i "pandas.Timestamp.min PR02" \
77-
-i "pandas.Timestamp.resolution PR02" \
7875
-i "pandas.core.groupby.DataFrameGroupBy.plot PR02" \
7976
-i "pandas.core.groupby.SeriesGroupBy.plot PR02" \
8077
-i "pandas.core.resample.Resampler.quantile PR01,PR07" \

pandas/_libs/tslibs/timestamps.pyx

+77-7
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ class MinMaxReso:
200200
201201
See also: timedeltas.MinMaxReso
202202
"""
203-
def __init__(self, name):
203+
def __init__(self, name, docstring):
204204
self._name = name
205+
self.__doc__ = docstring
205206

206207
def __get__(self, obj, type=None):
207208
cls = Timestamp
@@ -216,11 +217,15 @@ class MinMaxReso:
216217

217218
if obj is None:
218219
# i.e. this is on the class, default to nanos
219-
return cls(val)
220+
result = cls(val)
220221
elif self._name == "resolution":
221-
return Timedelta._from_value_and_reso(val, obj._creso)
222+
result = Timedelta._from_value_and_reso(val, obj._creso)
222223
else:
223-
return Timestamp._from_value_and_reso(val, obj._creso, tz=None)
224+
result = Timestamp._from_value_and_reso(val, obj._creso, tz=None)
225+
226+
result.__doc__ = self.__doc__
227+
228+
return result
224229

225230
def __set__(self, obj, value):
226231
raise AttributeError(f"{self._name} is not settable.")
@@ -235,9 +240,74 @@ cdef class _Timestamp(ABCTimestamp):
235240
dayofweek = _Timestamp.day_of_week
236241
dayofyear = _Timestamp.day_of_year
237242

238-
min = MinMaxReso("min")
239-
max = MinMaxReso("max")
240-
resolution = MinMaxReso("resolution") # GH#21336, GH#21365
243+
_docstring_min = """
244+
Returns the minimum bound possible for Timestamp.
245+
246+
This property provides access to the smallest possible value that
247+
can be represented by a Timestamp object.
248+
249+
Returns
250+
-------
251+
Timestamp
252+
253+
See Also
254+
--------
255+
Timestamp.max: Returns the maximum bound possible for Timestamp.
256+
Timestamp.resolution: Returns the smallest possible difference between
257+
non-equal Timestamp objects.
258+
259+
Examples
260+
--------
261+
>>> pd.Timestamp.min
262+
Timestamp('1677-09-21 00:12:43.145224193')
263+
"""
264+
265+
_docstring_max = """
266+
Returns the maximum bound possible for Timestamp.
267+
268+
This property provides access to the largest possible value that
269+
can be represented by a Timestamp object.
270+
271+
Returns
272+
-------
273+
Timestamp
274+
275+
See Also
276+
--------
277+
Timestamp.min: Returns the minimum bound possible for Timestamp.
278+
Timestamp.resolution: Returns the smallest possible difference between
279+
non-equal Timestamp objects.
280+
281+
Examples
282+
--------
283+
>>> pd.Timestamp.max
284+
Timestamp('2262-04-11 23:47:16.854775807')
285+
"""
286+
287+
_docstring_reso = """
288+
Returns the smallest possible difference between non-equal Timestamp objects.
289+
290+
The resolution value is determined by the underlying representation of time
291+
units and is equivalent to Timedelta(nanoseconds=1).
292+
293+
Returns
294+
-------
295+
Timedelta
296+
297+
See Also
298+
--------
299+
Timestamp.max: Returns the maximum bound possible for Timestamp.
300+
Timestamp.min: Returns the minimum bound possible for Timestamp.
301+
302+
Examples
303+
--------
304+
>>> pd.Timestamp.resolution
305+
Timedelta('0 days 00:00:00.000000001')
306+
"""
307+
308+
min = MinMaxReso("min", _docstring_min)
309+
max = MinMaxReso("max", _docstring_max)
310+
resolution = MinMaxReso("resolution", _docstring_reso) # GH#21336, GH#21365
241311

242312
@property
243313
def value(self) -> int:

0 commit comments

Comments
 (0)