Skip to content

Commit

Permalink
vresions
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Nov 2, 2024
1 parent d2725cb commit 62c1ac4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
10 changes: 5 additions & 5 deletions narwhals/_pandas_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
datetime64\[
(?P<time_unit>s|ms|us|ns) # Match time unit: s, ms, us, or ns
(?:, # Begin non-capturing group for optional timezone
\s? # Optional whitespace after comma
\s* # Optional whitespace after comma
(?P<time_zone> # Start named group for timezone
[a-zA-Z\/]+ # Match timezone name, e.g., UTC, America/New_York
(?: # Begin optional non-capturing group for offset
[+-]\d{2}:\d{2} # Match offset in format +HH:MM or -HH:MM
)? # End optional offset group
(?:[+-]\d{2}:\d{2})? # Optional offset in format +HH:MM or -HH:MM
| # OR
pytz\.FixedOffset\(\d+\) # Match pytz.FixedOffset with integer offset in parentheses
) # End time_zone group
)? # End optional timezone group
\] # Closing bracket
\] # Closing bracket for datetime64
$"""
PATTERN_PD_DATETIME = re.compile(PD_DATETIME_RGX, re.VERBOSE)
PA_DATETIME_RGX = r"""^
Expand Down
22 changes: 14 additions & 8 deletions tests/dtypes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,17 @@ def test_pandas_fixed_offset_1302() -> None:
pd.Series(pd.to_datetime(["2020-01-01T00:00:00.000000000+01:00"])),
series_only=True,
).dtype
assert result == nw.Datetime("ns", "UTC+01:00")
result = nw.from_native(
pd.Series(pd.to_datetime(["2020-01-01T00:00:00.000000000+01:00"])).convert_dtypes(
dtype_backend="pyarrow"
),
series_only=True,
).dtype
assert result == nw.Datetime("ns", "+01:00")
if PANDAS_VERSION >= (2,):
assert result == nw.Datetime("ns", "UTC+01:00")
else: # pragma: no cover
assert result == nw.Datetime("ns", "pytz.FixedOffset(60)")
if PANDAS_VERSION >= (2,):
result = nw.from_native(
pd.Series(
pd.to_datetime(["2020-01-01T00:00:00.000000000+01:00"])
).convert_dtypes(dtype_backend="pyarrow"),
series_only=True,
).dtype
assert result == nw.Datetime("ns", "+01:00")
else: # pragma: no cover
pass

0 comments on commit 62c1ac4

Please sign in to comment.