Skip to content

Commit e9a2e66

Browse files
DOC: Fix SA01 ES01 for pandas.Timestamp.to_pydatetime (#58701)
* DOC: add SA01,ES01 for pandas.Timestamp.to_pydatetime * DOC: add SA01,ES01 for pandas.Timestamp.to_pydatetime * DOC: remove SA01,ES01 for pandas.Timestamp.to_pydatetime * DOC: change docstring in sync with pandas.Timestamp.to_pydatetime
1 parent 7d3474a commit e9a2e66

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
301301
-i "pandas.Timestamp.to_julian_date SA01" \
302302
-i "pandas.Timestamp.to_numpy PR01" \
303303
-i "pandas.Timestamp.to_period PR01,SA01" \
304-
-i "pandas.Timestamp.to_pydatetime PR01,SA01" \
305304
-i "pandas.Timestamp.today SA01" \
306305
-i "pandas.Timestamp.toordinal SA01" \
307306
-i "pandas.Timestamp.tz SA01" \

pandas/_libs/tslibs/nattype.pyx

+24-1
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,30 @@ class NaTType(_NaT):
882882
"""
883883
Convert a Timestamp object to a native Python datetime object.
884884
885-
If warn=True, issue a warning if nanoseconds is nonzero.
885+
This method is useful for when you need to utilize a pandas Timestamp
886+
object in contexts where native Python datetime objects are expected
887+
or required. The conversion discards the nanoseconds component, and a
888+
warning can be issued in such cases if desired.
889+
890+
Parameters
891+
----------
892+
warn : bool, default True
893+
If True, issues a warning when the timestamp includes nonzero
894+
nanoseconds, as these will be discarded during the conversion.
895+
896+
Returns
897+
-------
898+
datetime.datetime or NaT
899+
Returns a datetime.datetime object representing the timestamp,
900+
with year, month, day, hour, minute, second, and microsecond components.
901+
If the timestamp is NaT (Not a Time), returns NaT.
902+
903+
See Also
904+
--------
905+
datetime.datetime : The standard Python datetime class that this method
906+
returns.
907+
Timestamp.timestamp : Convert a Timestamp object to POSIX timestamp.
908+
Timestamp.to_datetime64 : Convert a Timestamp object to numpy.datetime64.
886909
887910
Examples
888911
--------

pandas/_libs/tslibs/timestamps.pyx

+24-1
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,30 @@ cdef class _Timestamp(ABCTimestamp):
11961196
"""
11971197
Convert a Timestamp object to a native Python datetime object.
11981198
1199-
If warn=True, issue a warning if nanoseconds is nonzero.
1199+
This method is useful for when you need to utilize a pandas Timestamp
1200+
object in contexts where native Python datetime objects are expected
1201+
or required. The conversion discards the nanoseconds component, and a
1202+
warning can be issued in such cases if desired.
1203+
1204+
Parameters
1205+
----------
1206+
warn : bool, default True
1207+
If True, issues a warning when the timestamp includes nonzero
1208+
nanoseconds, as these will be discarded during the conversion.
1209+
1210+
Returns
1211+
-------
1212+
datetime.datetime or NaT
1213+
Returns a datetime.datetime object representing the timestamp,
1214+
with year, month, day, hour, minute, second, and microsecond components.
1215+
If the timestamp is NaT (Not a Time), returns NaT.
1216+
1217+
See Also
1218+
--------
1219+
datetime.datetime : The standard Python datetime class that this method
1220+
returns.
1221+
Timestamp.timestamp : Convert a Timestamp object to POSIX timestamp.
1222+
Timestamp.to_datetime64 : Convert a Timestamp object to numpy.datetime64.
12001223
12011224
Examples
12021225
--------

0 commit comments

Comments
 (0)