Skip to content

Commit d2d4e5c

Browse files
committed
Fix tz_localize(None) with Arrow timestamp
1 parent 25d63e8 commit d2d4e5c

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2953,7 +2953,7 @@ def _dt_tz_localize(
29532953
if nonexistent_pa is None:
29542954
raise NotImplementedError(f"{nonexistent=} is not supported")
29552955
if tz is None:
2956-
result = self._pa_array.cast(pa.timestamp(self.dtype.pyarrow_dtype.unit))
2956+
result = pc.local_timestamp(self._pa_array)
29572957
else:
29582958
result = pc.assume_timezone(
29592959
self._pa_array, str(tz), ambiguous=ambiguous, nonexistent=nonexistent_pa

pandas/tests/extension/test_arrow.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2686,7 +2686,6 @@ def test_dt_tz_localize_unsupported_tz_options():
26862686
ser.dt.tz_localize("UTC", nonexistent="NaT")
26872687

26882688

2689-
@pytest.mark.xfail(reason="Converts to UTC before localizing GH#61780")
26902689
def test_dt_tz_localize_none():
26912690
ser = pd.Series(
26922691
[datetime(year=2023, month=1, day=2, hour=3), None],

0 commit comments

Comments
 (0)