From bfe5a22899d0d362af544ada2b1359341e487649 Mon Sep 17 00:00:00 2001 From: abonte <6319051+abonte@users.noreply.github.com> Date: Sat, 11 May 2024 20:14:28 +0200 Subject: [PATCH] DOC: Enforce Numpy Docstring Validation - Timestamp.strftime and Timestamp.isoformat (#58677) * DOC: add See also section to Timestamp.strftime and Timestamp.isoformat * ensure NaT.strftime docstring matches Timestamp.strftime --- ci/code_checks.sh | 2 -- pandas/_libs/tslibs/nattype.pyx | 6 ++++++ pandas/_libs/tslibs/timestamps.pyx | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index a7fd196647619..05688c2ccca68 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -283,7 +283,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timestamp.hour GL08" \ -i "pandas.Timestamp.is_leap_year SA01" \ -i "pandas.Timestamp.isocalendar SA01" \ - -i "pandas.Timestamp.isoformat SA01" \ -i "pandas.Timestamp.isoweekday SA01" \ -i "pandas.Timestamp.max PR02" \ -i "pandas.Timestamp.microsecond GL08" \ @@ -299,7 +298,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timestamp.resolution PR02,PR07,SA01" \ -i "pandas.Timestamp.round SA01" \ -i "pandas.Timestamp.second GL08" \ - -i "pandas.Timestamp.strftime SA01" \ -i "pandas.Timestamp.strptime PR01,SA01" \ -i "pandas.Timestamp.time SA01" \ -i "pandas.Timestamp.timestamp SA01" \ diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 84e696fc687a3..cf7c20d84c2d4 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -692,6 +692,12 @@ class NaTType(_NaT): See strftime documentation for more information on the format string: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior. + See Also + -------- + Timestamp.isoformat : Return the time formatted according to ISO 8601. + pd.to_datetime : Convert argument to datetime. + Period.strftime : Format a single Period. + Examples -------- >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 47a0dddb5ed15..bf6d3debc306a 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1008,6 +1008,12 @@ cdef class _Timestamp(ABCTimestamp): ------- str + See Also + -------- + Timestamp.strftime : Return a formatted string. + Timestamp.isocalendar : Return a tuple containing ISO year, week number and + weekday. + Examples -------- >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651') @@ -1549,6 +1555,12 @@ class Timestamp(_Timestamp): See strftime documentation for more information on the format string: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior. + See Also + -------- + Timestamp.isoformat : Return the time formatted according to ISO 8601. + pd.to_datetime : Convert argument to datetime. + Period.strftime : Format a single Period. + Examples -------- >>> ts = pd.Timestamp('2020-03-14T15:32:52.192548651')