From c224bf0f9f22d4409a21b789a3ab290c01b7ca9b Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Wed, 12 Nov 2025 10:36:29 -0300 Subject: [PATCH 1/9] added example for timezone string for Timestamp.now --- pandas/_libs/tslibs/timestamps.pyx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index afbefd9b84461..4e42589489693 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1917,7 +1917,9 @@ class Timestamp(_Timestamp): Return new Timestamp object representing current time local to tz. This method returns a new `Timestamp` object that represents the current time. - If a timezone is provided, the current time will be localized to that timezone. + If a timezone is provided, either through a timezone object or an IANA + standard timezone identifier, the current time will be localized to that + timezone. Otherwise, it returns the current local time. Parameters @@ -1936,6 +1938,12 @@ class Timestamp(_Timestamp): >>> pd.Timestamp.now() # doctest: +SKIP Timestamp('2020-11-16 22:06:16.378782') + If you want a specific timezone, in this case 'Brazil/East': + + >>> pd.Timestamp.now('Brazil/East') + Timestamp('2025-11-11 22:17:59.609943-03:00) + + Analogous for ``pd.NaT``: >>> pd.NaT.now() From c566e7c8373dd3231584a7193c93e3674691c9de Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Wed, 12 Nov 2025 11:21:12 -0300 Subject: [PATCH 2/9] synced nat.now doc --- pandas/_libs/tslibs/nattype.pyx | 9 +++++++-- pandas/_libs/tslibs/timestamps.pyx | 3 +-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 49c1c46ea4935..727fef38d69d4 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -1072,8 +1072,13 @@ class NaTType(_NaT): Examples -------- - >>> pd.Timestamp.utcnow() # doctest: +SKIP - Timestamp('2020-11-16 22:50:18.092888+0000', tz='UTC') + >>> pd.Timestamp.now() # doctest: +SKIP + Timestamp('2020-11-16 22:06:16.378782') + + If you want a specific timezone, in this case 'Brazil/East': + + >>> pd.Timestamp.now('Brazil/East') # doctest: +SKIP + Timestamp('2025-11-11 22:17:59.609943-03:00) """, ) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 4e42589489693..bae56905f193c 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1940,10 +1940,9 @@ class Timestamp(_Timestamp): If you want a specific timezone, in this case 'Brazil/East': - >>> pd.Timestamp.now('Brazil/East') + >>> pd.Timestamp.now('Brazil/East') # doctest: +SKIP Timestamp('2025-11-11 22:17:59.609943-03:00) - Analogous for ``pd.NaT``: >>> pd.NaT.now() From a89bb53714a84aaecb9d77c7ba2870629129ee57 Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Wed, 12 Nov 2025 21:12:45 -0300 Subject: [PATCH 3/9] Revert "synced nat.now doc" This reverts commit c566e7c8373dd3231584a7193c93e3674691c9de. --- pandas/_libs/tslibs/nattype.pyx | 9 ++------- pandas/_libs/tslibs/timestamps.pyx | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 727fef38d69d4..49c1c46ea4935 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -1072,13 +1072,8 @@ class NaTType(_NaT): Examples -------- - >>> pd.Timestamp.now() # doctest: +SKIP - Timestamp('2020-11-16 22:06:16.378782') - - If you want a specific timezone, in this case 'Brazil/East': - - >>> pd.Timestamp.now('Brazil/East') # doctest: +SKIP - Timestamp('2025-11-11 22:17:59.609943-03:00) + >>> pd.Timestamp.utcnow() # doctest: +SKIP + Timestamp('2020-11-16 22:50:18.092888+0000', tz='UTC') """, ) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index bae56905f193c..4e42589489693 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1940,9 +1940,10 @@ class Timestamp(_Timestamp): If you want a specific timezone, in this case 'Brazil/East': - >>> pd.Timestamp.now('Brazil/East') # doctest: +SKIP + >>> pd.Timestamp.now('Brazil/East') Timestamp('2025-11-11 22:17:59.609943-03:00) + Analogous for ``pd.NaT``: >>> pd.NaT.now() From e33302f0a2cff17eb49f6de44cdbaec789a6eb51 Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Thu, 13 Nov 2025 08:56:02 -0300 Subject: [PATCH 4/9] modified nat.now to match --- pandas/_libs/tslibs/nattype.pyx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 49c1c46ea4935..57065816841e3 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -1256,11 +1256,13 @@ class NaTType(_NaT): now = _make_nat_func( "now", - """ +""" Return new Timestamp object representing current time local to tz. This method returns a new `Timestamp` object that represents the current time. - If a timezone is provided, the current time will be localized to that timezone. + If a timezone is provided, either through a timezone object or an IANA + standard timezone identifier, the current time will be localized to that + timezone. Otherwise, it returns the current local time. Parameters @@ -1279,6 +1281,12 @@ class NaTType(_NaT): >>> pd.Timestamp.now() # doctest: +SKIP Timestamp('2020-11-16 22:06:16.378782') + If you want a specific timezone, in this case 'Brazil/East': + + >>> pd.Timestamp.now('Brazil/East') + Timestamp('2025-11-11 22:17:59.609943-03:00) + + Analogous for ``pd.NaT``: >>> pd.NaT.now() From 8ffbd438a43ab369266bb69323d722faf124d7f7 Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Thu, 13 Nov 2025 09:00:33 -0300 Subject: [PATCH 5/9] modified nat.now to matchtimestamp.now --- pandas/_libs/tslibs/nattype.pyx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 57065816841e3..b92f2bf615801 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -1288,7 +1288,34 @@ class NaTType(_NaT): Analogous for ``pd.NaT``: + """ + Return new Timestamp object representing current time local to tz. + + This method returns a new `Timestamp` object that represents the current time. + If a timezone is provided, the current time will be localized to that timezone. + Otherwise, it returns the current local time. + + Parameters + ---------- + tz : str or timezone object, default None + Timezone to localize to. + + See Also + -------- + to_datetime : Convert argument to datetime. + Timestamp.utcnow : Return a new Timestamp representing UTC day and time. + Timestamp.today : Return the current time in the local timezone. + Examples + -------- + >>> pd.Timestamp.now() # doctest: +SKIP + Timestamp('2020-11-16 22:06:16.378782') + + Analogous for ``pd.NaT``: + + >>> pd.NaT.now() + NaT + """ >>> pd.NaT.now() NaT """, From 29d33642ad03d7804bfaf1d60bc2629c48a2bad9 Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Thu, 13 Nov 2025 09:09:54 -0300 Subject: [PATCH 6/9] ran pre-commit --- pandas/_libs/tslibs/nattype.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index b92f2bf615801..97e1d1e69469a 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -1309,7 +1309,7 @@ class NaTType(_NaT): Examples -------- >>> pd.Timestamp.now() # doctest: +SKIP - Timestamp('2020-11-16 22:06:16.378782') + Timestamp("2020-11-16 22:06:16.378782") Analogous for ``pd.NaT``: From 8869dcc85ec7d3d216ede50d2c8b056e48c085d2 Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Thu, 13 Nov 2025 09:50:21 -0300 Subject: [PATCH 7/9] fix docstring errors --- pandas/_libs/tslibs/nattype.pyx | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 97e1d1e69469a..43d344f43f18e 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -1256,7 +1256,7 @@ class NaTType(_NaT): now = _make_nat_func( "now", -""" + """ Return new Timestamp object representing current time local to tz. This method returns a new `Timestamp` object that represents the current time. @@ -1287,35 +1287,8 @@ class NaTType(_NaT): Timestamp('2025-11-11 22:17:59.609943-03:00) - Analogous for ``pd.NaT``: - """ - Return new Timestamp object representing current time local to tz. - - This method returns a new `Timestamp` object that represents the current time. - If a timezone is provided, the current time will be localized to that timezone. - Otherwise, it returns the current local time. - - Parameters - ---------- - tz : str or timezone object, default None - Timezone to localize to. - - See Also - -------- - to_datetime : Convert argument to datetime. - Timestamp.utcnow : Return a new Timestamp representing UTC day and time. - Timestamp.today : Return the current time in the local timezone. - - Examples - -------- - >>> pd.Timestamp.now() # doctest: +SKIP - Timestamp("2020-11-16 22:06:16.378782") - Analogous for ``pd.NaT``: - >>> pd.NaT.now() - NaT - """ >>> pd.NaT.now() NaT """, From aeb150d4688b9197f7e6730435104674a4e3cd7a Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Thu, 13 Nov 2025 10:13:01 -0300 Subject: [PATCH 8/9] fixed double linebreak in timestamps.pyx --- pandas/_libs/tslibs/timestamps.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 4e42589489693..2dff239642663 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1943,7 +1943,6 @@ class Timestamp(_Timestamp): >>> pd.Timestamp.now('Brazil/East') Timestamp('2025-11-11 22:17:59.609943-03:00) - Analogous for ``pd.NaT``: >>> pd.NaT.now() From 512ccc2e2a0e3b074bfccaebd5d7fd17609b1d8b Mon Sep 17 00:00:00 2001 From: arturkenzo Date: Thu, 13 Nov 2025 11:11:40 -0300 Subject: [PATCH 9/9] fixed mismatch in docstrings --- pandas/_libs/tslibs/nattype.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 43d344f43f18e..8bd150792419b 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -1286,7 +1286,6 @@ class NaTType(_NaT): >>> pd.Timestamp.now('Brazil/East') Timestamp('2025-11-11 22:17:59.609943-03:00) - Analogous for ``pd.NaT``: >>> pd.NaT.now()