{"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":4286,"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":4268,"sourceCodeEnd":4304,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L4268-L4304","documentation":"Raised by ArrowExtensionArray._dt_tz_localize when `ambiguous` is not the default 'raise'. Unlike the rounding path, tz_localize does delegate to pyarrow's assume_timezone, but pandas only wires up the 'raise' case for the ambiguous parameter on the arrow backend; bool-array/'infer'/'NaT' disambiguation is not implemented.","triggerScenarios":"Calling `ser.dt.tz_localize('US/Eastern', ambiguous='infer')` (or any non-'raise' ambiguous value) on a tz-naive timestamp[pyarrow] Series. Note the nonexistent parameter has partial support here, but ambiguous does not.","commonSituations":"Reusing the rich ambiguous handling that datetime64[ns] supports when switching to pyarrow-backed timestamps; ambiguous DST-transition logs.","solutions":["Leave ambiguous at 'raise' (the default) and ensure your data does not fall in a DST-ambiguous interval.","For full ambiguous handling, cast to datetime64[ns, tz] via the numpy path: localize an object/datetime64 Series first, then convert to arrow if needed."],"exampleFix":"# before\nser.dt.tz_localize('US/Eastern', ambiguous='infer')\n# after\nser.dt.tz_localize('US/Eastern')   # or use datetime64[ns] path","handlingStrategy":"validation","validationCode":"if ambiguous != 'raise':\n    raise ValueError(\"arrow tz_localize does not support non-default ambiguous\")\nser.dt.tz_localize(tz)","typeGuard":"def arrow_localize_accepts_ambiguous(ambiguous) -> bool:\n    return ambiguous == 'raise'","tryCatchPattern":"try:\n    out = ser.dt.tz_localize(tz, ambiguous=ambiguous)\nexcept NotImplementedError as e:\n    if \"ambiguous=\" in str(e):\n        out = ser.astype(object).dt.tz_localize(tz, ambiguous=ambiguous)\n    else:\n        raise","preventionTips":["Leave ambiguous='raise' for arrow tz_localize","Use the datetime64[ns] path when you need bool/infer disambiguation"],"tags":["pyarrow","datetime-accessor","timezone","dst","not-implemented","arrow-extension"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}