Skip to content

Commit d3eda3c

Browse files
Changes to fix docstring issue with pandas.Timestamp.hour
1 parent ac69522 commit d3eda3c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
211211
-i "pandas.Timestamp.fold GL08" \
212212
-i "pandas.Timestamp.fromordinal SA01" \
213213
-i "pandas.Timestamp.fromtimestamp PR01,SA01" \
214-
-i "pandas.Timestamp.hour GL08" \
215214
-i "pandas.Timestamp.max PR02" \
216215
-i "pandas.Timestamp.microsecond GL08" \
217216
-i "pandas.Timestamp.min PR02" \

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,36 @@ cdef class _Timestamp(ABCTimestamp):
590590
field, freq_name, month_kw, self._creso)
591591
return out[0]
592592

593+
def hour(self) -> int:
594+
"""
595+
Returns the hour component of the timestamp.
596+
597+
Extended Summary
598+
--------
599+
The hour is represented as an integer ranging from 0 to 23, where 0 corresponds
600+
to midnight (00:00) and 23 corresponds to the last hour of the day (23:00).
601+
602+
Returns
603+
--------
604+
int
605+
The hour component of the timestamp as an integer between 0 and 23.
606+
607+
See Also
608+
--------
609+
Timestamp.minute : Similar property indicating the minute of the timestamp.
610+
611+
Examples
612+
--------
613+
>>> ts = pd.Timestamp('2020-03-14T12:32:52.192548651')
614+
>>> ts.hour()
615+
12
616+
617+
>>> ts = pd.Timestamp('2020-03-14T22:43:12.192547851')
618+
>>> ts.hour()
619+
22
620+
"""
621+
return self.hour
622+
593623
@property
594624
def is_month_start(self) -> bool:
595625
"""

0 commit comments

Comments
 (0)