Skip to content

DOC: Fix SA01 ES01 for pandas.Timestamp.to_pydatetime #58701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timestamp.to_julian_date SA01" \
-i "pandas.Timestamp.to_numpy PR01" \
-i "pandas.Timestamp.to_period PR01,SA01" \
-i "pandas.Timestamp.to_pydatetime PR01,SA01" \
-i "pandas.Timestamp.today SA01" \
-i "pandas.Timestamp.toordinal SA01" \
-i "pandas.Timestamp.tz SA01" \
Expand Down
25 changes: 24 additions & 1 deletion pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,30 @@ class NaTType(_NaT):
"""
Convert a Timestamp object to a native Python datetime object.

If warn=True, issue a warning if nanoseconds is nonzero.
This method is useful for when you need to utilize a pandas Timestamp
object in contexts where native Python datetime objects are expected
or required. The conversion discards the nanoseconds component, and a
warning can be issued in such cases if desired.

Parameters
----------
warn : bool, default True
If True, issues a warning when the timestamp includes nonzero
nanoseconds, as these will be discarded during the conversion.

Returns
-------
datetime.datetime or NaT
Returns a datetime.datetime object representing the timestamp,
with year, month, day, hour, minute, second, and microsecond components.
If the timestamp is NaT (Not a Time), returns NaT.

See Also
--------
datetime.datetime : The standard Python datetime class that this method
returns.
Timestamp.timestamp : Convert a Timestamp object to POSIX timestamp.
Timestamp.to_datetime64 : Convert a Timestamp object to numpy.datetime64.

Examples
--------
Expand Down
25 changes: 24 additions & 1 deletion pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,30 @@ cdef class _Timestamp(ABCTimestamp):
"""
Convert a Timestamp object to a native Python datetime object.

If warn=True, issue a warning if nanoseconds is nonzero.
This method is useful for when you need to utilize a pandas Timestamp
object in contexts where native Python datetime objects are expected
or required. The conversion discards the nanoseconds component, and a
warning can be issued in such cases if desired.

Parameters
----------
warn : bool, default True
If True, issues a warning when the timestamp includes nonzero
nanoseconds, as these will be discarded during the conversion.

Returns
-------
datetime.datetime or NaT
Returns a datetime.datetime object representing the timestamp,
with year, month, day, hour, minute, second, and microsecond components.
If the timestamp is NaT (Not a Time), returns NaT.

See Also
--------
datetime.datetime : The standard Python datetime class that this method
returns.
Timestamp.timestamp : Convert a Timestamp object to POSIX timestamp.
Timestamp.to_datetime64 : Convert a Timestamp object to numpy.datetime64.

Examples
--------
Expand Down
Loading