pandas-dev/pandas · error · NotImplementedError
{pa_type}
Error message
{pa_type} What it means
In _mode, temporal pyarrow types are cast to int32 (32-bit) or int64 (64-bit) before value_counts. The branch explicitly raises NotImplementedError(pa_type) for any other temporal bit width. As of writing, pyarrow only produces 32- and 64-bit temporal types, so this is a forward-compatible guard against new pyarrow temporal widths (e.g. a future narrower date/time type).
Source
Thrown at pandas/core/arrays/arrow/array.py:3133
Parameters
----------
dropna : bool, default True
Don't consider counts of NA values.
Returns
-------
same type as self
Sorted, if possible.
"""
pa_type = self._pa_array.type
if pa.types.is_temporal(pa_type):
nbits = pa_type.bit_width
if nbits == 32:
data = self._pa_array.cast(pa.int32())
elif nbits == 64:
data = self._pa_array.cast(pa.int64())
else:
raise NotImplementedError(pa_type)
else:
data = self._pa_array
if dropna:
data = data.drop_null()
res = pc.value_counts(data)
most_common = res.field("values").filter(
pc.equal(res.field("counts"), pc.max(res.field("counts")))
)
if pa.types.is_temporal(pa_type):
most_common = most_common.cast(pa_type)
most_common = most_common.take(pc.array_sort_indices(most_common))
return self._from_pyarrow_array(most_common)
def _validate_setitem_value(self, value):View on GitHub (pinned to 3b7651241d)
Solutions
- Cast the column to a standard 64-bit temporal dtype (e.g. timestamp[ns]) before calling .mode().
- Upgrade or downgrade pyarrow to a version whose temporal types are 32/64-bit only.
- Compute mode manually via .value_counts() after casting to int64.
Example fix
// before
s = pd.Series([...], dtype="timestamp[unit][pyarrow]") # exotic width
s.mode()
// after
s = s.astype("timestamp[ns][pyarrow]")
s.mode() Defensive patterns
Strategy: try-catch
Validate before calling
import pyarrow as pa
def mode_supported(arr) -> bool:
t = arr._pa_array.type
if pa.types.is_temporal(t):
return t.bit_width in (32, 64)
return True Type guard
import pyarrow as pa
def is_standard_temporal(arr) -> bool:
t = arr._pa_array.type
return not pa.types.is_temporal(t) or t.bit_width in (32, 64) Try / catch
try:
s.mode()
except NotImplementedError:
s.astype("timestamp[ns][pyarrow]").mode() Prevention
- Use 64-bit temporal dtypes for downstream statistics.
- Cast exotic temporal types to timestamp[ns] before .mode().
When it happens
Trigger: Computing .mode() on an ArrowExtensionArray whose pyarrow type is temporal with a bit_width other than 32 or 64 (currently not producible by stock pyarrow).
Common situations: Future pyarrow release introducing a new temporal width; custom pyarrow extension types registered as temporal.
Related errors
- Converting strings to {pa_type} is not implemented.
- {type(self)} does not support reshape as backed by a 1D pyar
- interpolate is not implemented for dtype={self.dtype}
- Invalid side: {side}. Side must be one of 'left', 'right', '
- invalid normalization form
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/cbf495839c857683.
Report an issue: GitHub.