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: Added docstring to Timestamp.tzinfo #61134

Closed
wants to merge 3 commits into from
Closed
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 @@ -78,7 +78,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timestamp.max PR02" \
-i "pandas.Timestamp.min PR02" \
-i "pandas.Timestamp.resolution PR02" \
-i "pandas.Timestamp.tzinfo GL08" \
-i "pandas.core.groupby.DataFrameGroupBy.plot PR02" \
-i "pandas.core.groupby.SeriesGroupBy.plot PR02" \
-i "pandas.core.resample.Resampler.quantile PR01,PR07" \
Expand Down
22 changes: 22 additions & 0 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2977,6 +2977,28 @@ timedelta}, default 'raise'
"""
return self.tzinfo

@property
def tzinfo(self):
"""
Returns the timezone information of the Timestamp.

For pandas-specific timezone operations, the `tz` property is the
recommended interface.
Comment on lines +2985 to +2986
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessarily true. Could you remove this statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know! I just assumed that tz was preferred because it already had a docstring but tzinfo didn't. I will remove


See Also
--------
Timestamp.tz : Alias for tzinfo.
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
Timestamp.tz_localize : Localize the Timestamp to a timezone.

Examples
--------
>>> ts = pd.Timestamp(1584226800, unit='s', tz='Europe/Stockholm')
>>> ts.tzinfo
zoneinfo.ZoneInfo(key='Europe/Stockholm')
"""
return super().tzinfo

@tz.setter
def tz(self, value):
# GH 3746: Prevent localizing or converting the index by setting tz
Expand Down