Skip to content

Commit 5700efe

Browse files
DOC: Enforce Numpy Docstring Validation (Issue #59458) (#59622)
* adding docstring for Timestamp properties * updating code_checks.sh * removing extra line * fixing code_checks.sh
1 parent 67bec1f commit 5700efe

File tree

2 files changed

+115
-5
lines changed

2 files changed

+115
-5
lines changed

ci/code_checks.sh

-5
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
161161
-i "pandas.TimedeltaIndex.seconds SA01" \
162162
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
163163
-i "pandas.Timestamp.fold GL08" \
164-
-i "pandas.Timestamp.hour GL08" \
165164
-i "pandas.Timestamp.max PR02" \
166-
-i "pandas.Timestamp.microsecond GL08" \
167165
-i "pandas.Timestamp.min PR02" \
168-
-i "pandas.Timestamp.minute GL08" \
169-
-i "pandas.Timestamp.month GL08" \
170166
-i "pandas.Timestamp.nanosecond GL08" \
171167
-i "pandas.Timestamp.resolution PR02" \
172-
-i "pandas.Timestamp.second GL08" \
173168
-i "pandas.Timestamp.tzinfo GL08" \
174169
-i "pandas.Timestamp.value GL08" \
175170
-i "pandas.Timestamp.year GL08" \

pandas/_libs/tslibs/timestamps.pyx

+115
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,121 @@ cdef class _Timestamp(ABCTimestamp):
984984
"""
985985
return super().day
986986
987+
@property
988+
def month(self) -> int:
989+
"""
990+
Return the month of the Timestamp.
991+
992+
Returns
993+
-------
994+
int
995+
The month of the Timestamp.
996+
997+
See Also
998+
--------
999+
Timestamp.day : Return the day of the year.
1000+
Timestamp.year : Return the year of the week.
1001+
1002+
Examples
1003+
--------
1004+
>>> ts = pd.Timestamp("2024-08-31 16:16:30")
1005+
>>> ts.month
1006+
8
1007+
"""
1008+
return super().month
1009+
1010+
@property
1011+
def hour(self) -> int:
1012+
"""
1013+
Return the hour of the Timestamp.
1014+
1015+
Returns
1016+
-------
1017+
int
1018+
The hour of the Timestamp.
1019+
1020+
See Also
1021+
--------
1022+
Timestamp.minute : Return the minute of the Timestamp.
1023+
Timestamp.second : Return the second of the Timestamp.
1024+
1025+
Examples
1026+
--------
1027+
>>> ts = pd.Timestamp("2024-08-31 16:16:30")
1028+
>>> ts.hour
1029+
16
1030+
"""
1031+
return super().hour
1032+
1033+
@property
1034+
def minute(self) -> int:
1035+
"""
1036+
Return the minute of the Timestamp.
1037+
1038+
Returns
1039+
-------
1040+
int
1041+
The minute of the Timestamp.
1042+
1043+
See Also
1044+
--------
1045+
Timestamp.hour : Return the hour of the Timestamp.
1046+
Timestamp.second : Return the second of the Timestamp.
1047+
1048+
Examples
1049+
--------
1050+
>>> ts = pd.Timestamp("2024-08-31 16:16:30")
1051+
>>> ts.minute
1052+
16
1053+
"""
1054+
return super().minute
1055+
1056+
@property
1057+
def second(self) -> int:
1058+
"""
1059+
Return the second of the Timestamp.
1060+
1061+
Returns
1062+
-------
1063+
int
1064+
The second of the Timestamp.
1065+
1066+
See Also
1067+
--------
1068+
Timestamp.microsecond : Return the microsecond of the Timestamp.
1069+
Timestamp.minute : Return the minute of the Timestamp.
1070+
1071+
Examples
1072+
--------
1073+
>>> ts = pd.Timestamp("2024-08-31 16:16:30")
1074+
>>> ts.second
1075+
30
1076+
"""
1077+
return super().second
1078+
1079+
@property
1080+
def microsecond(self) -> int:
1081+
"""
1082+
Return the microsecond of the Timestamp.
1083+
1084+
Returns
1085+
-------
1086+
int
1087+
The microsecond of the Timestamp.
1088+
1089+
See Also
1090+
--------
1091+
Timestamp.second : Return the second of the Timestamp.
1092+
Timestamp.minute : Return the minute of the Timestamp.
1093+
1094+
Examples
1095+
--------
1096+
>>> ts = pd.Timestamp("2024-08-31 16:16:30.2304")
1097+
>>> ts.microsecond
1098+
230400
1099+
"""
1100+
return super().microsecond
1101+
9871102
@property
9881103
def week(self) -> int:
9891104
"""

0 commit comments

Comments
 (0)