Skip to content

Commit 2f75794

Browse files
DOC: Fix docstrings for Timestamp: tz_localize, tzname, utcfromtimestamp (pandas-dev#59484)
* updated docstring for pandas.Timestamp.tz_localize, pandas.Timestamp.tzname and pandas.Timestamp.utcfromtimestamp * trimmed whitespace * reducing line length * updating NaT docstrings to match for timestamps
1 parent 66a2111 commit 2f75794

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

ci/code_checks.sh

-3
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
220220
-i "pandas.Timestamp.to_period PR01,SA01" \
221221
-i "pandas.Timestamp.today SA01" \
222222
-i "pandas.Timestamp.toordinal SA01" \
223-
-i "pandas.Timestamp.tz_localize SA01" \
224223
-i "pandas.Timestamp.tzinfo GL08" \
225-
-i "pandas.Timestamp.tzname SA01" \
226224
-i "pandas.Timestamp.unit SA01" \
227-
-i "pandas.Timestamp.utcfromtimestamp PR01,SA01" \
228225
-i "pandas.Timestamp.utcoffset SA01" \
229226
-i "pandas.Timestamp.utctimetuple SA01" \
230227
-i "pandas.Timestamp.value GL08" \

pandas/_libs/tslibs/nattype.pyx

+29
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,13 @@ class NaTType(_NaT):
626626
"""
627627
Return time zone name.
628628
629+
This method returns the name of the Timestamp's time zone as a string.
630+
631+
See Also
632+
--------
633+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
634+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
635+
629636
Examples
630637
--------
631638
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
@@ -765,6 +772,21 @@ class NaTType(_NaT):
765772
766773
Construct a timezone-aware UTC datetime from a POSIX timestamp.
767774
775+
This method creates a datetime object from a POSIX timestamp, keeping the
776+
Timestamp object's timezone.
777+
778+
Parameters
779+
----------
780+
ts : float
781+
POSIX timestamp.
782+
783+
See Also
784+
--------
785+
Timezone.tzname : Return time zone name.
786+
Timestamp.utcnow : Return a new Timestamp representing UTC day and time.
787+
Timestamp.fromtimestamp : Transform timestamp[, tz] to tz's local
788+
time from POSIX timestamp.
789+
768790
Notes
769791
-----
770792
Timestamp.utcfromtimestamp behavior differs from datetime.utcfromtimestamp
@@ -1432,6 +1454,13 @@ default 'raise'
14321454
TypeError
14331455
If the Timestamp is tz-aware and tz is not None.
14341456
1457+
See Also
1458+
--------
1459+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
1460+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
1461+
DatetimeIndex.tz_localize : Localize a DatetimeIndex to a specific time zone.
1462+
datetime.datetime.astimezone : Convert a datetime object to another time zone.
1463+
14351464
Examples
14361465
--------
14371466
Create a naive timestamp object:

pandas/_libs/tslibs/timestamps.pyx

+29
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,21 @@ class Timestamp(_Timestamp):
15601560
15611561
Construct a timezone-aware UTC datetime from a POSIX timestamp.
15621562
1563+
This method creates a datetime object from a POSIX timestamp, keeping the
1564+
Timestamp object's timezone.
1565+
1566+
Parameters
1567+
----------
1568+
ts : float
1569+
POSIX timestamp.
1570+
1571+
See Also
1572+
--------
1573+
Timezone.tzname : Return time zone name.
1574+
Timestamp.utcnow : Return a new Timestamp representing UTC day and time.
1575+
Timestamp.fromtimestamp : Transform timestamp[, tz] to tz's local
1576+
time from POSIX timestamp.
1577+
15631578
Notes
15641579
-----
15651580
Timestamp.utcfromtimestamp behavior differs from datetime.utcfromtimestamp
@@ -1735,6 +1750,13 @@ class Timestamp(_Timestamp):
17351750
"""
17361751
Return time zone name.
17371752
1753+
This method returns the name of the Timestamp's time zone as a string.
1754+
1755+
See Also
1756+
--------
1757+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
1758+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
1759+
17381760
Examples
17391761
--------
17401762
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
@@ -2468,6 +2490,13 @@ default 'raise'
24682490
TypeError
24692491
If the Timestamp is tz-aware and tz is not None.
24702492
2493+
See Also
2494+
--------
2495+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
2496+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
2497+
DatetimeIndex.tz_localize : Localize a DatetimeIndex to a specific time zone.
2498+
datetime.datetime.astimezone : Convert a datetime object to another time zone.
2499+
24712500
Examples
24722501
--------
24732502
Create a naive timestamp object:

0 commit comments

Comments
 (0)