From becca3002243062194789f4968e1be8deee9b402 Mon Sep 17 00:00:00 2001 From: ankit-dhokariya Date: Mon, 26 Aug 2024 22:09:21 -0700 Subject: [PATCH 1/4] adding docstring for Timestamp properties --- pandas/_libs/tslibs/timestamps.pyx | 116 +++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index a9463ce8ad044..0e5b8643124e3 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -984,6 +984,122 @@ cdef class _Timestamp(ABCTimestamp): """ return super().day + @property + def month(self) -> int: + """ + Return the month of the Timestamp. + + Returns + ------- + int + The month of the Timestamp. + + See Also + -------- + Timestamp.day : Return the day of the year. + Timestamp.year : Return the year of the week. + + Examples + -------- + >>> ts = pd.Timestamp("2024-08-31 16:16:30") + >>> ts.month + 8 + """ + return super().month + + @property + def hour(self) -> int: + """ + Return the hour of the Timestamp. + + Returns + ------- + int + The hour of the Timestamp. + + See Also + -------- + Timestamp.minute : Return the minute of the Timestamp. + Timestamp.second : Return the second of the Timestamp. + + Examples + + -------- + >>> ts = pd.Timestamp("2024-08-31 16:16:30") + >>> ts.hour + 16 + """ + return super().hour + + @property + def minute(self) -> int: + """ + Return the minute of the Timestamp. + + Returns + ------- + int + The minute of the Timestamp. + + See Also + -------- + Timestamp.hour : Return the hour of the Timestamp. + Timestamp.second : Return the second of the Timestamp. + + Examples + -------- + >>> ts = pd.Timestamp("2024-08-31 16:16:30") + >>> ts.minute + 16 + """ + return super().minute + + @property + def second(self) -> int: + """ + Return the second of the Timestamp. + + Returns + ------- + int + The second of the Timestamp. + + See Also + -------- + Timestamp.microsecond : Return the microsecond of the Timestamp. + Timestamp.minute : Return the minute of the Timestamp. + + Examples + -------- + >>> ts = pd.Timestamp("2024-08-31 16:16:30") + >>> ts.second + 30 + """ + return super().second + + @property + def microsecond(self) -> int: + """ + Return the microsecond of the Timestamp. + + Returns + ------- + int + The microsecond of the Timestamp. + + See Also + -------- + Timestamp.second : Return the second of the Timestamp. + Timestamp.minute : Return the minute of the Timestamp. + + Examples + -------- + >>> ts = pd.Timestamp("2024-08-31 16:16:30.2304") + >>> ts.microsecond + 230400 + """ + return super().microsecond + @property def week(self) -> int: """ From f6c6539968c2f9a60e63961e894e1c942237dbac Mon Sep 17 00:00:00 2001 From: ankit-dhokariya Date: Mon, 26 Aug 2024 22:09:50 -0700 Subject: [PATCH 2/4] updating code_checks.sh --- ci/code_checks.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 2d260c78a8f33..e8a7f04ef5caf 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -163,15 +163,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.TimedeltaIndex.seconds SA01" \ -i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \ -i "pandas.Timestamp.fold GL08" \ - -i "pandas.Timestamp.hour GL08" \ -i "pandas.Timestamp.max PR02" \ - -i "pandas.Timestamp.microsecond GL08" \ -i "pandas.Timestamp.min PR02" \ - -i "pandas.Timestamp.minute GL08" \ - -i "pandas.Timestamp.month GL08" \ - -i "pandas.Timestamp.nanosecond GL08" \ -i "pandas.Timestamp.resolution PR02" \ - -i "pandas.Timestamp.second GL08" \ -i "pandas.Timestamp.tzinfo GL08" \ -i "pandas.Timestamp.value GL08" \ -i "pandas.Timestamp.year GL08" \ From 480a57bc1e230a9076d1b2f7b6991c4c44810354 Mon Sep 17 00:00:00 2001 From: ankit-dhokariya Date: Mon, 26 Aug 2024 22:31:45 -0700 Subject: [PATCH 3/4] removing extra line --- pandas/_libs/tslibs/timestamps.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 0e5b8643124e3..ec976f17af396 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1023,7 +1023,6 @@ cdef class _Timestamp(ABCTimestamp): Timestamp.second : Return the second of the Timestamp. Examples - -------- >>> ts = pd.Timestamp("2024-08-31 16:16:30") >>> ts.hour From 593d4620c8e71c01e78d59773e1da04d2426600b Mon Sep 17 00:00:00 2001 From: ankit-dhokariya Date: Mon, 26 Aug 2024 23:36:56 -0700 Subject: [PATCH 4/4] fixing code_checks.sh --- ci/code_checks.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index e8a7f04ef5caf..6123b272fad0f 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -165,6 +165,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timestamp.fold GL08" \ -i "pandas.Timestamp.max PR02" \ -i "pandas.Timestamp.min PR02" \ + -i "pandas.Timestamp.nanosecond GL08" \ -i "pandas.Timestamp.resolution PR02" \ -i "pandas.Timestamp.tzinfo GL08" \ -i "pandas.Timestamp.value GL08" \