Skip to content
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

DOC: Fix docstrings for Timestamp: tz_localize, tzname, utcfromtimestamp #59484

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
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timestamp.to_period PR01,SA01" \
-i "pandas.Timestamp.today SA01" \
-i "pandas.Timestamp.toordinal SA01" \
-i "pandas.Timestamp.tz_localize SA01" \
-i "pandas.Timestamp.tzinfo GL08" \
-i "pandas.Timestamp.tzname SA01" \
-i "pandas.Timestamp.unit SA01" \
-i "pandas.Timestamp.utcfromtimestamp PR01,SA01" \
-i "pandas.Timestamp.utcoffset SA01" \
-i "pandas.Timestamp.utctimetuple SA01" \
-i "pandas.Timestamp.value GL08" \
Expand Down
29 changes: 29 additions & 0 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,13 @@ class NaTType(_NaT):
"""
Return time zone name.

This method returns the name of the Timestamp's time zone as a string.

See Also
--------
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.

Examples
--------
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
Expand Down Expand Up @@ -765,6 +772,21 @@ class NaTType(_NaT):

Construct a timezone-aware UTC datetime from a POSIX timestamp.

This method creates a datetime object from a POSIX timestamp, keeping the
Timestamp object's timezone.

Parameters
----------
ts : float
POSIX timestamp.

See Also
--------
Timezone.tzname : Return time zone name.
Timestamp.utcnow : Return a new Timestamp representing UTC day and time.
Timestamp.fromtimestamp : Transform timestamp[, tz] to tz's local
time from POSIX timestamp.

Notes
-----
Timestamp.utcfromtimestamp behavior differs from datetime.utcfromtimestamp
Expand Down Expand Up @@ -1432,6 +1454,13 @@ default 'raise'
TypeError
If the Timestamp is tz-aware and tz is not None.

See Also
--------
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
DatetimeIndex.tz_localize : Localize a DatetimeIndex to a specific time zone.
datetime.datetime.astimezone : Convert a datetime object to another time zone.

Examples
--------
Create a naive timestamp object:
Expand Down
29 changes: 29 additions & 0 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,21 @@ class Timestamp(_Timestamp):

Construct a timezone-aware UTC datetime from a POSIX timestamp.

This method creates a datetime object from a POSIX timestamp, keeping the
Timestamp object's timezone.

Parameters
----------
ts : float
POSIX timestamp.

See Also
--------
Timezone.tzname : Return time zone name.
Timestamp.utcnow : Return a new Timestamp representing UTC day and time.
Timestamp.fromtimestamp : Transform timestamp[, tz] to tz's local
time from POSIX timestamp.

Notes
-----
Timestamp.utcfromtimestamp behavior differs from datetime.utcfromtimestamp
Expand Down Expand Up @@ -1735,6 +1750,13 @@ class Timestamp(_Timestamp):
"""
Return time zone name.

This method returns the name of the Timestamp's time zone as a string.

See Also
--------
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.

Examples
--------
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
Expand Down Expand Up @@ -2468,6 +2490,13 @@ default 'raise'
TypeError
If the Timestamp is tz-aware and tz is not None.

See Also
--------
Timestamp.tzinfo : Returns the timezone information of the Timestamp.
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
DatetimeIndex.tz_localize : Localize a DatetimeIndex to a specific time zone.
datetime.datetime.astimezone : Convert a datetime object to another time zone.

Examples
--------
Create a naive timestamp object:
Expand Down