Skip to content

Commit 310f8a8

Browse files
authored
BUG: dt.tz with ArrowDtype returned string (#55072)
1 parent 67b1e8b commit 310f8a8

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

doc/source/whatsnew/v2.1.1.rst

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Bug fixes
3535
~~~~~~~~~
3636
- Fixed bug for :class:`ArrowDtype` raising ``NotImplementedError`` for fixed-size list (:issue:`55000`)
3737
- Fixed bug in :meth:`DataFrame.stack` with ``future_stack=True`` and columns a non-:class:`MultiIndex` consisting of tuples (:issue:`54948`)
38+
- Fixed bug in :meth:`Series.dt.tz` with :class:`ArrowDtype` where a string was returned instead of a ``tzinfo`` object (:issue:`55003`)
3839
- Fixed bug in :meth:`Series.pct_change` and :meth:`DataFrame.pct_change` showing unnecessary ``FutureWarning`` (:issue:`54981`)
3940

4041
.. ---------------------------------------------------------------------------

pandas/core/arrays/arrow/array.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pandas._libs.tslibs import (
1919
Timedelta,
2020
Timestamp,
21+
timezones,
2122
)
2223
from pandas.compat import (
2324
pa_version_under7p0,
@@ -2425,7 +2426,7 @@ def _dt_time(self):
24252426

24262427
@property
24272428
def _dt_tz(self):
2428-
return self.dtype.pyarrow_dtype.tz
2429+
return timezones.maybe_get_tz(self.dtype.pyarrow_dtype.tz)
24292430

24302431
@property
24312432
def _dt_unit(self):

pandas/tests/extension/test_arrow.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import pytest
3232

3333
from pandas._libs import lib
34+
from pandas._libs.tslibs import timezones
3435
from pandas.compat import (
3536
PY311,
3637
is_ci_environment,
@@ -2432,7 +2433,7 @@ def test_dt_tz(tz):
24322433
dtype=ArrowDtype(pa.timestamp("ns", tz=tz)),
24332434
)
24342435
result = ser.dt.tz
2435-
assert result == tz
2436+
assert result == timezones.maybe_get_tz(tz)
24362437

24372438

24382439
def test_dt_isocalendar():

0 commit comments

Comments
 (0)