diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 2d260c78a8f33..6123b272fad0f 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -163,15 +163,10 @@ 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" \ diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index a9463ce8ad044..ec976f17af396 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -984,6 +984,121 @@ 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: """