pandas-dev/pandas · error · NotImplementedError

is not supported

Error message

{ambiguous=} is not supported

What it means

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.

Solutions

  1. Leave ambiguous at 'raise' (the default) and ensure your data does not fall in a DST-ambiguous interval.
  2. 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.

Example fix

# before
ser.dt.tz_localize('US/Eastern', ambiguous='infer')
# after
ser.dt.tz_localize('US/Eastern')   # or use datetime64[ns] path
Defensive patterns

Strategy: validation

Validate before calling

if ambiguous != 'raise':
    raise ValueError("arrow tz_localize does not support non-default ambiguous")
ser.dt.tz_localize(tz)

Type guard

def arrow_localize_accepts_ambiguous(ambiguous) -> bool:
    return ambiguous == 'raise'

Try / catch

try:
    out = ser.dt.tz_localize(tz, ambiguous=ambiguous)
except NotImplementedError as e:
    if "ambiguous=" in str(e):
        out = ser.astype(object).dt.tz_localize(tz, ambiguous=ambiguous)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: Reusing the rich ambiguous handling that datetime64[ns] supports when switching to pyarrow-backed timestamps; ambiguous DST-transition logs.

Related errors


AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11). Data as JSON: /api/errors/ab4fb84c41d89462. Report an issue: GitHub.

Appendix: source

Thrown at pandas/core/arrays/arrow/array.py:4286

        if pa.types.is_date(self.dtype.pyarrow_dtype):
            raise ValueError(
                f"to_pydatetime cannot be called with {self.dtype.pyarrow_dtype} type. "
                "Convert to pyarrow timestamp type."
            )
        data = self._pa_array.to_pylist()
        if self._dtype.pyarrow_dtype.unit == "ns":
            data = [None if ts is None else ts.to_pydatetime(warn=False) for ts in data]
        return Series(data, dtype=object)

    def _dt_tz_localize(
        self,
        tz,
        ambiguous: TimeAmbiguous = "raise",
        nonexistent: TimeNonexistent = "raise",
    ) -> Self:
        if ambiguous != "raise":
            raise NotImplementedError(f"{ambiguous=} is not supported")
        nonexistent_pa = {
            "raise": "raise",
            "shift_backward": "earliest",
            "shift_forward": "latest",
        }.get(
            nonexistent,  # type: ignore[arg-type]
            None,
        )
        if nonexistent_pa is None:
            raise NotImplementedError(f"{nonexistent=} is not supported")
        if tz is None:
            result = pc.local_timestamp(self._pa_array)
        else:
            result = pc.assume_timezone(
                self._pa_array, str(tz), ambiguous=ambiguous, nonexistent=nonexistent_pa
            )
        return self._from_pyarrow_array(result)

View on GitHub (pinned to 3b7651241d)