Skip to content

Commit ee32f76

Browse files
authored
REGR: DatetimeTZDtype __from_arrow__ interprets UTC values as wall time (#56922)
1 parent 32f8932 commit ee32f76

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pandas/core/dtypes/dtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ def __from_arrow__(self, array: pa.Array | pa.ChunkedArray) -> DatetimeArray:
919919
else:
920920
np_arr = array.to_numpy()
921921

922-
return DatetimeArray._from_sequence(np_arr, dtype=self, copy=False)
922+
return DatetimeArray._simple_new(np_arr, dtype=self)
923923

924924
def __setstate__(self, state) -> None:
925925
# for pickle compat. __get_state__ is defined in the

pandas/tests/arrays/datetimes/test_constructors.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def test_2d(self, order):
222222
("s", "ns", "US/Central", "Asia/Kolkata", COARSE_TO_FINE_SAFE),
223223
],
224224
)
225-
def test_from_arrowtest_from_arrow_with_different_units_and_timezones_with_(
225+
def test_from_arrow_with_different_units_and_timezones_with(
226226
pa_unit, pd_unit, pa_tz, pd_tz, data
227227
):
228228
pa = pytest.importorskip("pyarrow")
@@ -232,9 +232,8 @@ def test_from_arrowtest_from_arrow_with_different_units_and_timezones_with_(
232232
dtype = DatetimeTZDtype(unit=pd_unit, tz=pd_tz)
233233

234234
result = dtype.__from_arrow__(arr)
235-
expected = DatetimeArray._from_sequence(
236-
np.array(data, dtype=f"datetime64[{pa_unit}]").astype(f"datetime64[{pd_unit}]"),
237-
dtype=dtype,
235+
expected = DatetimeArray._from_sequence(data, dtype=f"M8[{pa_unit}, UTC]").astype(
236+
dtype, copy=False
238237
)
239238
tm.assert_extension_array_equal(result, expected)
240239

0 commit comments

Comments
 (0)