{"record":{"id":"ae0a1f1fc1a5d897","repo":"pandas-dev/pandas","slug":"nonexistent-is-not-supported-ae0a1f","errorCode":null,"errorMessage":"{nonexistent=} is not supported","messagePattern":"(.+?) is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":4296,"sourceCode":"\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\n    def _dt_tz_convert(self, tz) -> Self:\n        if self.dtype.pyarrow_dtype.tz is None:\n            raise TypeError(\n                \"Cannot convert tz-naive timestamps, use tz_localize to localize\"\n            )\n        current_unit = self.dtype.pyarrow_dtype.unit\n        result = self._pa_array.cast(pa.timestamp(current_unit, tz))\n        return self._from_pyarrow_array(result)\n\n","sourceCodeStart":4278,"sourceCodeEnd":4314,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L4278-L4314","documentation":"Raised by ArrowExtensionArray._dt_tz_localize when the `nonexistent` argument is not one of {'raise','shift_backward','shift_forward'}. These three are mapped to pyarrow's assume_timezone 'raise'/'earliest'/'latest' options; any other value (e.g. 'NaT', 'timedelta') has no arrow equivalent and is rejected.","triggerScenarios":"Calling `ser.dt.tz_localize('US/Eastern', nonexistent='NaT')` (or 'shift_forward' is OK, but 'timedelta'/'NaT' are not) on a tz-naive timestamp[pyarrow] Series whose times fall in a forward-DST gap.","commonSituations":"Using nonexistent strategies supported on datetime64[ns] but absent from the arrow assume_timezone mapping.","solutions":["Use one of the supported values: 'raise' (default), 'shift_backward', or 'shift_forward'.","If you need 'NaT' behavior, pre-filter or shift the offending timestamps manually before localizing."],"exampleFix":"# before\nser.dt.tz_localize('US/Eastern', nonexistent='NaT')\n# after\nser.dt.tz_localize('US/Eastern', nonexistent='shift_forward')","handlingStrategy":"validation","validationCode":"ALLOWED = {'raise', 'shift_backward', 'shift_forward'}\nif nonexistent not in ALLOWED:\n    raise ValueError(f\"{nonexistent!r} unsupported on arrow tz_localize; use one of {ALLOWED}\")\nser.dt.tz_localize(tz, nonexistent=nonexistent)","typeGuard":"def is_arrow_supported_nonexistent(v) -> bool:\n    return v in {'raise', 'shift_backward', 'shift_forward'}","tryCatchPattern":"try:\n    out = ser.dt.tz_localize(tz, nonexistent=nonexistent)\nexcept NotImplementedError as e:\n    if \"nonexistent=\" in str(e):\n        out = ser.dt.tz_localize(tz, nonexistent='shift_forward')\n    else:\n        raise","preventionTips":["Restrict nonexistent to raise/shift_backward/shift_forward for arrow","Avoid 'NaT'/'timedelta' which have no arrow mapping"],"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"}