From a471f006c0b9eb749e4f1bfa7db4cb5162099bd0 Mon Sep 17 00:00:00 2001 From: John Hendricks Date: Sun, 16 Mar 2025 09:49:14 -0400 Subject: [PATCH 1/3] Added docstring to Timestamp.tzinfo --- pandas/_libs/tslibs/timestamps.pyx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 452ba0fe869ee..09c589ec36f0b 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -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. + + 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 self.tzinfo + @tz.setter def tz(self, value): # GH 3746: Prevent localizing or converting the index by setting tz From 92ae5fce0a963e8e58275f1d64e75ee084e6293e Mon Sep 17 00:00:00 2001 From: John Hendricks Date: Sun, 16 Mar 2025 09:58:15 -0400 Subject: [PATCH 2/3] Removed Timestamp.tzinfo from code_checks.sh --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 6ce43725fecc9..2410f19d32a66 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -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" \ From d213ec273c6a810f71b19a87d9efe6b3b7b33e94 Mon Sep 17 00:00:00 2001 From: John Hendricks Date: Sun, 16 Mar 2025 10:28:15 -0400 Subject: [PATCH 3/3] Resolved infinite recursion for pandas.Timestamp.tzinfo --- pandas/_libs/tslibs/timestamps.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 09c589ec36f0b..163e600f36014 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -2997,7 +2997,7 @@ timedelta}, default 'raise' >>> ts.tzinfo zoneinfo.ZoneInfo(key='Europe/Stockholm') """ - return self.tzinfo + return super().tzinfo @tz.setter def tz(self, value):