Skip to content

Commit

Permalink
DOC: Enforce Numpy Docstring Validation (Issue #59458) (#59622)
Browse files Browse the repository at this point in the history
* adding docstring for Timestamp properties

* updating code_checks.sh

* removing extra line

* fixing code_checks.sh
  • Loading branch information
ankit-dhokariya authored Aug 27, 2024
1 parent 67bec1f commit 5700efe
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 5 deletions.
5 changes: 0 additions & 5 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,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" \
Expand Down
115 changes: 115 additions & 0 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down

0 comments on commit 5700efe

Please sign in to comment.