Skip to content

DOC: Enforce Numpy Docstring Validation for DatetimeIndex #58353

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

Merged
merged 13 commits into from
Apr 22, 2024
20 changes: 4 additions & 16 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,16 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.DataFrame.to_markdown SA01" \
-i "pandas.DataFrame.to_parquet RT03" \
-i "pandas.DataFrame.var PR01,RT03,SA01" \
-i "pandas.DatetimeIndex.ceil SA01" \
-i "pandas.DatetimeIndex.date SA01" \
-i "pandas.DatetimeIndex.day_of_year SA01" \
-i "pandas.DatetimeIndex.dayofyear SA01" \
-i "pandas.DatetimeIndex.floor SA01" \
-i "pandas.DatetimeIndex.freqstr SA01" \
-i "pandas.DatetimeIndex.indexer_at_time PR01,RT03" \
-i "pandas.DatetimeIndex.indexer_between_time RT03" \
-i "pandas.DatetimeIndex.inferred_freq SA01" \
-i "pandas.DatetimeIndex.is_leap_year SA01" \
-i "pandas.DatetimeIndex.quarter SA01" \
-i "pandas.DatetimeIndex.round SA01" \
-i "pandas.DatetimeIndex.snap PR01,RT03,SA01" \
-i "pandas.DatetimeIndex.snap PR01,RT03" \
-i "pandas.DatetimeIndex.std PR01,RT03" \
-i "pandas.DatetimeIndex.time SA01" \
-i "pandas.DatetimeIndex.timetz SA01" \
-i "pandas.DatetimeIndex.to_period RT03" \
-i "pandas.DatetimeIndex.to_pydatetime RT03,SA01" \
-i "pandas.DatetimeIndex.tz SA01" \
Expand Down Expand Up @@ -289,7 +283,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Series.div PR07" \
-i "pandas.Series.droplevel SA01" \
-i "pandas.Series.dt.as_unit PR01,PR02" \
-i "pandas.Series.dt.ceil PR01,PR02,SA01" \
-i "pandas.Series.dt.ceil PR01,PR02" \
-i "pandas.Series.dt.components SA01" \
-i "pandas.Series.dt.date SA01" \
-i "pandas.Series.dt.day_name PR01,PR02" \
Expand All @@ -298,20 +292,17 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Series.dt.days SA01" \
-i "pandas.Series.dt.days_in_month SA01" \
-i "pandas.Series.dt.daysinmonth SA01" \
-i "pandas.Series.dt.floor PR01,PR02,SA01" \
-i "pandas.Series.dt.floor PR01,PR02" \
-i "pandas.Series.dt.freq GL08" \
-i "pandas.Series.dt.is_leap_year SA01" \
-i "pandas.Series.dt.microseconds SA01" \
-i "pandas.Series.dt.month_name PR01,PR02" \
-i "pandas.Series.dt.nanoseconds SA01" \
-i "pandas.Series.dt.normalize PR01" \
-i "pandas.Series.dt.quarter SA01" \
-i "pandas.Series.dt.qyear GL08" \
-i "pandas.Series.dt.round PR01,PR02,SA01" \
-i "pandas.Series.dt.round PR01,PR02" \
-i "pandas.Series.dt.seconds SA01" \
-i "pandas.Series.dt.strftime PR01,PR02" \
-i "pandas.Series.dt.time SA01" \
-i "pandas.Series.dt.timetz SA01" \
-i "pandas.Series.dt.to_period PR01,PR02,RT03" \
-i "pandas.Series.dt.total_seconds PR01" \
-i "pandas.Series.dt.tz SA01" \
Expand Down Expand Up @@ -432,14 +423,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timedelta.total_seconds SA01" \
-i "pandas.Timedelta.view SA01" \
-i "pandas.TimedeltaIndex.as_unit RT03,SA01" \
-i "pandas.TimedeltaIndex.ceil SA01" \
-i "pandas.TimedeltaIndex.components SA01" \
-i "pandas.TimedeltaIndex.days SA01" \
-i "pandas.TimedeltaIndex.floor SA01" \
-i "pandas.TimedeltaIndex.inferred_freq SA01" \
-i "pandas.TimedeltaIndex.microseconds SA01" \
-i "pandas.TimedeltaIndex.nanoseconds SA01" \
-i "pandas.TimedeltaIndex.round SA01" \
-i "pandas.TimedeltaIndex.seconds SA01" \
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
-i "pandas.Timestamp PR07,SA01" \
Expand Down
5 changes: 5 additions & 0 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,11 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
------
ValueError if the `freq` cannot be converted.

See Also
--------
DatetimeIndex.floor : Perform floor operation on the data to the specified `freq`.
DatetimeIndex.snap : Snap time stamps to nearest occurring frequency.

Notes
-----
If the timestamps have a timezone, {op}ing will take place relative to the
Expand Down
20 changes: 20 additions & 0 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,14 @@ def time(self) -> npt.NDArray[np.object_]:

The time part of the Timestamps.

See Also
--------
DatetimeIndex.timetz : Returns numpy array of :class:`datetime.time`
objects with timezones. The time part of the Timestamps.
DatetimeIndex.date : Returns numpy array of python :class:`datetime.date`
objects. Namely, the date part of Timestamps without time and timezone
information.

Examples
--------
For Series:
Expand Down Expand Up @@ -1428,6 +1436,12 @@ def timetz(self) -> npt.NDArray[np.object_]:

The time part of the Timestamps.

See Also
--------
DatetimeIndex.time : Returns numpy array of :class:`datetime.time` objects.
The time part of the Timestamps.
DatetimeIndex.tz : Return the timezone.

Examples
--------
For Series:
Expand Down Expand Up @@ -1836,6 +1850,12 @@ def isocalendar(self) -> DataFrame:
"""
The quarter of the date.

See Also
--------
DatetimeIndex.snap : Snap time stamps to nearest occurring frequency.
DatetimeIndex.time : Returns numpy array of datetime.time objects.
The time part of the Timestamps.

Examples
--------
For Series:
Expand Down
7 changes: 7 additions & 0 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ def snap(self, freq: Frequency = "S") -> DatetimeIndex:
-------
DatetimeIndex

See Also
--------
DatetimeIndex.round : Perform round operation on the data to the
specified `freq`.
DatetimeIndex.floor : Perform floor operation on the data to the
specified `freq`.

Examples
--------
>>> idx = pd.DatetimeIndex(
Expand Down
Loading