{"record":{"id":"ab4fb84c41d89462","repo":"pandas-dev/pandas","slug":"ambiguous-is-not-supported-ab4fb8","errorCode":null,"errorMessage":"{ambiguous=} is not supported","messagePattern":"(.+?) is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":4258,"sourceCode":"\n        if pa.types.is_date(self.dtype.pyarrow_dtype):\n            raise ValueError(\n                f\"to_pydatetime cannot be called with {self.dtype.pyarrow_dtype} type. \"\n                \"Convert to pyarrow timestamp type.\"\n            )\n        data = self._pa_array.to_pylist()\n        if self._dtype.pyarrow_dtype.unit == \"ns\":\n            data = [None if ts is None else ts.to_pydatetime(warn=False) for ts in data]\n        return Series(data, dtype=object)\n\n    def _dt_tz_localize(\n        self,\n        tz,\n        ambiguous: TimeAmbiguous = \"raise\",\n        nonexistent: TimeNonexistent = \"raise\",\n    ) -> Self:\n        if ambiguous != \"raise\":\n            raise NotImplementedError(f\"{ambiguous=} is not supported\")\n        nonexistent_pa = {\n            \"raise\": \"raise\",\n            \"shift_backward\": \"earliest\",\n            \"shift_forward\": \"latest\",\n        }.get(\n            nonexistent,  # type: ignore[arg-type]\n            None,\n        )\n        if nonexistent_pa is None:\n            raise NotImplementedError(f\"{nonexistent=} is not supported\")\n        if tz is None:\n            result = pc.local_timestamp(self._pa_array)\n        else:\n            result = pc.assume_timezone(\n                self._pa_array, str(tz), ambiguous=ambiguous, nonexistent=nonexistent_pa\n            )\n        return self._from_pyarrow_array(result)\n","sourceCodeStart":4240,"sourceCodeEnd":4276,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/arrow/array.py#L4240-L4276","documentation":"Raised by ArrowExtensionArray._dt_tz_localize when `ambiguous != \"raise\"`. The pyarrow assume_timezone call underneath is invoked with ambiguous='raise' only; the ArrowExtensionArray path does not support 'infer', boolean arrays, or 'NaT' for the ambiguous parameter when localizing. Any non-'raise' value triggers NotImplementedError.","triggerScenarios":"Calling `s.dt.tz_localize(\"US/Eastern\", ambiguous=\"infer\")` or `ambiguous=[True,False,...]` on a tz-naive pyarrow timestamp Series whose wall-clock times fall in a DST fold. Reached via dt.tz_localize on timestamp[pyarrow].","commonSituations":"Localizing logs/telemetry timestamped in local wall-clock time crossing a fall-back DST boundary; porting localize code from datetime64[ns] that accepted infer/array ambiguous.","solutions":["Pre-disambiguate the fold before localizing, then localize with ambiguous='raise' on a clean subset.","Cast to datetime64[ns] for localization: `s.astype(\"datetime64[ns]\").dt.tz_localize(\"US/Eastern\", ambiguous=\"infer\")`.","Localize to UTC (no DST) if wall-clock semantics are not critical, then tz_convert.","Provide explicit per-row ambiguous flags via the numpy-backed path."],"exampleFix":"# before\ns.dt.tz_localize(\"US/Eastern\", ambiguous=\"infer\")  # NotImplementedError\n\n# after\nout = s.astype(\"datetime64[ns]\").dt.tz_localize(\"US/Eastern\", ambiguous=\"infer\")","handlingStrategy":"validation","validationCode":"def safe_tz_localize(s, tz, nonexistent=\"raise\"):\n    if ambiguous != \"raise\":\n        # pyarrow backend cannot resolve fold; use numpy backend\n        return s.astype(\"datetime64[ns]\").dt.tz_localize(tz, ambiguous=ambiguous, nonexistent=nonexistent)\n    return s.dt.tz_localize(tz, nonexistent=nonexistent)","typeGuard":"def needs_numpy_localize(ambiguous) -> bool:\n    return ambiguous != \"raise\"","tryCatchPattern":"try:\n    out = s.dt.tz_localize(tz, ambiguous=ambiguous)\nexcept NotImplementedError:\n    out = s.astype(\"datetime64[ns]\").dt.tz_localize(tz, ambiguous=ambiguous)","preventionTips":["Default ambiguous='raise' for pyarrow tz_localize.","Pre-disambiguate DST folds before localizing.","Cast to datetime64[ns] when array/boolean ambiguous resolution is required."],"tags":["pyarrow","datetime-accessor","dst","not-implemented"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}