From 3258589f4d6897bd10f4142226ab16c026b1e351 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Fri, 17 May 2024 23:15:12 +0530 Subject: [PATCH] DOC: add SA01 for pandas.Timestamp.tz_convert --- ci/code_checks.sh | 2 -- pandas/_libs/tslibs/nattype.pyx | 24 ++++++++++++++++++++++++ pandas/_libs/tslibs/timestamps.pyx | 12 ++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 2145a2721d146..340775ec6b7c2 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -247,7 +247,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.TimedeltaIndex.nanoseconds SA01" \ -i "pandas.TimedeltaIndex.seconds SA01" \ -i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \ - -i "pandas.Timestamp.astimezone SA01" \ -i "pandas.Timestamp.ceil SA01" \ -i "pandas.Timestamp.combine PR01,SA01" \ -i "pandas.Timestamp.ctime SA01" \ @@ -285,7 +284,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timestamp.today SA01" \ -i "pandas.Timestamp.toordinal SA01" \ -i "pandas.Timestamp.tz SA01" \ - -i "pandas.Timestamp.tz_convert SA01" \ -i "pandas.Timestamp.tz_localize SA01" \ -i "pandas.Timestamp.tzinfo GL08" \ -i "pandas.Timestamp.tzname SA01" \ diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 9a7f233ea8259..8319af2148918 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -822,6 +822,11 @@ class NaTType(_NaT): """ Convert timezone-aware Timestamp to another time zone. + This method is used to convert a timezone-aware Timestamp object to a + different time zone. The original UTC time remains the same; only the + time zone information is changed. If the Timestamp is timezone-naive, a + TypeError is raised. + Parameters ---------- tz : str, pytz.timezone, dateutil.tz.tzfile or None @@ -837,6 +842,13 @@ class NaTType(_NaT): TypeError If Timestamp is tz-naive. + See Also + -------- + Timestamp.tz_localize : Localize the Timestamp to a timezone. + DatetimeIndex.tz_convert : Convert a DatetimeIndex 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 timestamp object with UTC timezone: @@ -1264,6 +1276,11 @@ timedelta}, default 'raise' """ Convert timezone-aware Timestamp to another time zone. + This method is used to convert a timezone-aware Timestamp object to a + different time zone. The original UTC time remains the same; only the + time zone information is changed. If the Timestamp is timezone-naive, a + TypeError is raised. + Parameters ---------- tz : str, pytz.timezone, dateutil.tz.tzfile or None @@ -1279,6 +1296,13 @@ timedelta}, default 'raise' TypeError If Timestamp is tz-naive. + See Also + -------- + Timestamp.tz_localize : Localize the Timestamp to a timezone. + DatetimeIndex.tz_convert : Convert a DatetimeIndex 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 timestamp object with UTC timezone: diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index d092c13c7a24b..a33df56e65873 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -2470,6 +2470,11 @@ default 'raise' """ Convert timezone-aware Timestamp to another time zone. + This method is used to convert a timezone-aware Timestamp object to a + different time zone. The original UTC time remains the same; only the + time zone information is changed. If the Timestamp is timezone-naive, a + TypeError is raised. + Parameters ---------- tz : str, pytz.timezone, dateutil.tz.tzfile or None @@ -2485,6 +2490,13 @@ default 'raise' TypeError If Timestamp is tz-naive. + See Also + -------- + Timestamp.tz_localize : Localize the Timestamp to a timezone. + DatetimeIndex.tz_convert : Convert a DatetimeIndex 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 timestamp object with UTC timezone: