Skip to content

Commit 03c4f77

Browse files
gboekerpmhatre1
authored andcommitted
DOC: Enforce Numpy Docstring Validation for DatetimeIndex (pandas-dev#58353)
* fix line too long * add return for snap * undo return * fix docstring issues for DatetimeIndex.quarter * remove pandas.Series.dt.quarter from codechecks * fix docstring issues for DatetimeIndex.round * fix docstring issues for DatetimeIndex.time * fix docstring issues for DatetimeIndex.timetz * add see also for timetz * fix code check errors * delete round from code_checks * fix code check errors
1 parent fcc9f14 commit 03c4f77

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

ci/code_checks.sh

+4-16
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,16 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
107107
-i "pandas.DataFrame.to_markdown SA01" \
108108
-i "pandas.DataFrame.to_parquet RT03" \
109109
-i "pandas.DataFrame.var PR01,RT03,SA01" \
110-
-i "pandas.DatetimeIndex.ceil SA01" \
111110
-i "pandas.DatetimeIndex.date SA01" \
112111
-i "pandas.DatetimeIndex.day_of_year SA01" \
113112
-i "pandas.DatetimeIndex.dayofyear SA01" \
114-
-i "pandas.DatetimeIndex.floor SA01" \
115113
-i "pandas.DatetimeIndex.freqstr SA01" \
116114
-i "pandas.DatetimeIndex.indexer_at_time PR01,RT03" \
117115
-i "pandas.DatetimeIndex.indexer_between_time RT03" \
118116
-i "pandas.DatetimeIndex.inferred_freq SA01" \
119117
-i "pandas.DatetimeIndex.is_leap_year SA01" \
120-
-i "pandas.DatetimeIndex.quarter SA01" \
121-
-i "pandas.DatetimeIndex.round SA01" \
122-
-i "pandas.DatetimeIndex.snap PR01,RT03,SA01" \
118+
-i "pandas.DatetimeIndex.snap PR01,RT03" \
123119
-i "pandas.DatetimeIndex.std PR01,RT03" \
124-
-i "pandas.DatetimeIndex.time SA01" \
125-
-i "pandas.DatetimeIndex.timetz SA01" \
126120
-i "pandas.DatetimeIndex.to_period RT03" \
127121
-i "pandas.DatetimeIndex.to_pydatetime RT03,SA01" \
128122
-i "pandas.DatetimeIndex.tz SA01" \
@@ -286,7 +280,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
286280
-i "pandas.Series.div PR07" \
287281
-i "pandas.Series.droplevel SA01" \
288282
-i "pandas.Series.dt.as_unit PR01,PR02" \
289-
-i "pandas.Series.dt.ceil PR01,PR02,SA01" \
283+
-i "pandas.Series.dt.ceil PR01,PR02" \
290284
-i "pandas.Series.dt.components SA01" \
291285
-i "pandas.Series.dt.date SA01" \
292286
-i "pandas.Series.dt.day_name PR01,PR02" \
@@ -295,20 +289,17 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
295289
-i "pandas.Series.dt.days SA01" \
296290
-i "pandas.Series.dt.days_in_month SA01" \
297291
-i "pandas.Series.dt.daysinmonth SA01" \
298-
-i "pandas.Series.dt.floor PR01,PR02,SA01" \
292+
-i "pandas.Series.dt.floor PR01,PR02" \
299293
-i "pandas.Series.dt.freq GL08" \
300294
-i "pandas.Series.dt.is_leap_year SA01" \
301295
-i "pandas.Series.dt.microseconds SA01" \
302296
-i "pandas.Series.dt.month_name PR01,PR02" \
303297
-i "pandas.Series.dt.nanoseconds SA01" \
304298
-i "pandas.Series.dt.normalize PR01" \
305-
-i "pandas.Series.dt.quarter SA01" \
306299
-i "pandas.Series.dt.qyear GL08" \
307-
-i "pandas.Series.dt.round PR01,PR02,SA01" \
300+
-i "pandas.Series.dt.round PR01,PR02" \
308301
-i "pandas.Series.dt.seconds SA01" \
309302
-i "pandas.Series.dt.strftime PR01,PR02" \
310-
-i "pandas.Series.dt.time SA01" \
311-
-i "pandas.Series.dt.timetz SA01" \
312303
-i "pandas.Series.dt.to_period PR01,PR02,RT03" \
313304
-i "pandas.Series.dt.total_seconds PR01" \
314305
-i "pandas.Series.dt.tz SA01" \
@@ -428,14 +419,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
428419
-i "pandas.Timedelta.total_seconds SA01" \
429420
-i "pandas.Timedelta.view SA01" \
430421
-i "pandas.TimedeltaIndex.as_unit RT03,SA01" \
431-
-i "pandas.TimedeltaIndex.ceil SA01" \
432422
-i "pandas.TimedeltaIndex.components SA01" \
433423
-i "pandas.TimedeltaIndex.days SA01" \
434-
-i "pandas.TimedeltaIndex.floor SA01" \
435424
-i "pandas.TimedeltaIndex.inferred_freq SA01" \
436425
-i "pandas.TimedeltaIndex.microseconds SA01" \
437426
-i "pandas.TimedeltaIndex.nanoseconds SA01" \
438-
-i "pandas.TimedeltaIndex.round SA01" \
439427
-i "pandas.TimedeltaIndex.seconds SA01" \
440428
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
441429
-i "pandas.Timestamp PR07,SA01" \

pandas/core/arrays/datetimelike.py

+5
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,11 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
18251825
------
18261826
ValueError if the `freq` cannot be converted.
18271827
1828+
See Also
1829+
--------
1830+
DatetimeIndex.floor : Perform floor operation on the data to the specified `freq`.
1831+
DatetimeIndex.snap : Snap time stamps to nearest occurring frequency.
1832+
18281833
Notes
18291834
-----
18301835
If the timestamps have a timezone, {op}ing will take place relative to the

pandas/core/arrays/datetimes.py

+20
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,14 @@ def time(self) -> npt.NDArray[np.object_]:
13911391
13921392
The time part of the Timestamps.
13931393
1394+
See Also
1395+
--------
1396+
DatetimeIndex.timetz : Returns numpy array of :class:`datetime.time`
1397+
objects with timezones. The time part of the Timestamps.
1398+
DatetimeIndex.date : Returns numpy array of python :class:`datetime.date`
1399+
objects. Namely, the date part of Timestamps without time and timezone
1400+
information.
1401+
13941402
Examples
13951403
--------
13961404
For Series:
@@ -1428,6 +1436,12 @@ def timetz(self) -> npt.NDArray[np.object_]:
14281436
14291437
The time part of the Timestamps.
14301438
1439+
See Also
1440+
--------
1441+
DatetimeIndex.time : Returns numpy array of :class:`datetime.time` objects.
1442+
The time part of the Timestamps.
1443+
DatetimeIndex.tz : Return the timezone.
1444+
14311445
Examples
14321446
--------
14331447
For Series:
@@ -1836,6 +1850,12 @@ def isocalendar(self) -> DataFrame:
18361850
"""
18371851
The quarter of the date.
18381852
1853+
See Also
1854+
--------
1855+
DatetimeIndex.snap : Snap time stamps to nearest occurring frequency.
1856+
DatetimeIndex.time : Returns numpy array of datetime.time objects.
1857+
The time part of the Timestamps.
1858+
18391859
Examples
18401860
--------
18411861
For Series:

pandas/core/indexes/datetimes.py

+7
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,13 @@ def snap(self, freq: Frequency = "S") -> DatetimeIndex:
455455
-------
456456
DatetimeIndex
457457
458+
See Also
459+
--------
460+
DatetimeIndex.round : Perform round operation on the data to the
461+
specified `freq`.
462+
DatetimeIndex.floor : Perform floor operation on the data to the
463+
specified `freq`.
464+
458465
Examples
459466
--------
460467
>>> idx = pd.DatetimeIndex(

0 commit comments

Comments
 (0)