Skip to content

Commit e7e6e6c

Browse files
MichaelMoylesshreyas-dev
authored andcommitted
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 a541768 commit e7e6e6c

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

ci/code_checks.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ 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" \
226-
-i "pandas.Timestamp.utcfromtimestamp PR01,SA01" \
224+
-i "pandas.Timestamp.unit SA01" \
225+
-i "pandas.Timestamp.utcoffset SA01" \
226+
-i "pandas.Timestamp.utctimetuple SA01" \
227227
-i "pandas.Timestamp.value GL08" \
228228
-i "pandas.Timestamp.year GL08" \
229229
-i "pandas.api.extensions.ExtensionArray._pad_or_backfill PR01,RT03,SA01" \

pandas/_libs/tslibs/nattype.pyx

+29
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,13 @@ class NaTType(_NaT):
657657
"""
658658
Return time zone name.
659659
660+
This method returns the name of the Timestamp's time zone as a string.
661+
662+
See Also
663+
--------
664+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
665+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
666+
660667
Examples
661668
--------
662669
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
@@ -796,6 +803,21 @@ class NaTType(_NaT):
796803
797804
Construct a timezone-aware UTC datetime from a POSIX timestamp.
798805
806+
This method creates a datetime object from a POSIX timestamp, keeping the
807+
Timestamp object's timezone.
808+
809+
Parameters
810+
----------
811+
ts : float
812+
POSIX timestamp.
813+
814+
See Also
815+
--------
816+
Timezone.tzname : Return time zone name.
817+
Timestamp.utcnow : Return a new Timestamp representing UTC day and time.
818+
Timestamp.fromtimestamp : Transform timestamp[, tz] to tz's local
819+
time from POSIX timestamp.
820+
799821
Notes
800822
-----
801823
Timestamp.utcfromtimestamp behavior differs from datetime.utcfromtimestamp
@@ -1463,6 +1485,13 @@ default 'raise'
14631485
TypeError
14641486
If the Timestamp is tz-aware and tz is not None.
14651487
1488+
See Also
1489+
--------
1490+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
1491+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
1492+
DatetimeIndex.tz_localize : Localize a DatetimeIndex to a specific time zone.
1493+
datetime.datetime.astimezone : Convert a datetime object to another time zone.
1494+
14661495
Examples
14671496
--------
14681497
Create a naive timestamp object:

pandas/_libs/tslibs/timestamps.pyx

+29
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,21 @@ class Timestamp(_Timestamp):
15761576
15771577
Construct a timezone-aware UTC datetime from a POSIX timestamp.
15781578
1579+
This method creates a datetime object from a POSIX timestamp, keeping the
1580+
Timestamp object's timezone.
1581+
1582+
Parameters
1583+
----------
1584+
ts : float
1585+
POSIX timestamp.
1586+
1587+
See Also
1588+
--------
1589+
Timezone.tzname : Return time zone name.
1590+
Timestamp.utcnow : Return a new Timestamp representing UTC day and time.
1591+
Timestamp.fromtimestamp : Transform timestamp[, tz] to tz's local
1592+
time from POSIX timestamp.
1593+
15791594
Notes
15801595
-----
15811596
Timestamp.utcfromtimestamp behavior differs from datetime.utcfromtimestamp
@@ -1751,6 +1766,13 @@ class Timestamp(_Timestamp):
17511766
"""
17521767
Return time zone name.
17531768
1769+
This method returns the name of the Timestamp's time zone as a string.
1770+
1771+
See Also
1772+
--------
1773+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
1774+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
1775+
17541776
Examples
17551777
--------
17561778
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
@@ -2515,6 +2537,13 @@ default 'raise'
25152537
TypeError
25162538
If the Timestamp is tz-aware and tz is not None.
25172539
2540+
See Also
2541+
--------
2542+
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
2543+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
2544+
DatetimeIndex.tz_localize : Localize a DatetimeIndex to a specific time zone.
2545+
datetime.datetime.astimezone : Convert a datetime object to another time zone.
2546+
25182547
Examples
25192548
--------
25202549
Create a naive timestamp object:

0 commit comments

Comments
 (0)