pandas-dev/pandas · error · TypeError

dtype ' ' does not support operation 'quantile

Error message

dtype '{self.dtype}' does not support operation 'quantile'

What it means

_groupby_quantile rejects quantile on StringDtype-backed-by-arrow arrays with TypeError. Quantiles require ordering and arithmetic (interpolation); strings can be ordered but interpolation methods like 'linear'/'midpoint' are undefined. Rather than partially support some interpolations, pandas refuses the whole operation for string arrow types.

Solutions

  1. Filter numeric columns before quantile: df.groupby(key)[numeric_cols].quantile(q).
  2. If only ordering matters, use .rank() or .min()/.max() on string columns instead.
  3. Cast the column to a numeric/categorical type if it encodes ordered data.

Example fix

// before
df = pd.DataFrame({"k": ["a"], "v": ["x"]}, dtype={"v": "string[pyarrow]"})
df.groupby("k")["v"].quantile(0.5)
// after
df = pd.DataFrame({"k": ["a"], "v": [1]}, dtype={"v": "int64[pyarrow]"})
df.groupby("k")["v"].quantile(0.5)
Defensive patterns

Strategy: validation

Validate before calling

from pandas.core.arrays.string_ import StringDtype

def quantile_supported(dtype) -> bool:
    return not isinstance(dtype, StringDtype)

Type guard

def is_string_arrow_dtype(dtype) -> bool:
    from pandas.core.arrays.string_ import StringDtype
    return isinstance(dtype, StringDtype)

Try / catch

try:
    df.groupby("k")[col].quantile(0.5)
except TypeError:
    df.groupby("k")[numeric_cols].quantile(0.5)

Prevention

When it happens

Trigger: df.groupby('key')['string_col'].quantile(0.5) on a string[pyarrow] column.

Common situations: Generic .quantile() over all groupby columns; building summary statistics without dtype awareness.

Related errors


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

Appendix: source

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

            ids=ids,
            **kwargs,
        )
        return self._groupby_result_to_arrow(result)

    def _groupby_quantile(
        self,
        *,
        qs: npt.NDArray[np.float64],
        interpolation: Literal["linear", "lower", "higher", "nearest", "midpoint"],
        ids: npt.NDArray[np.intp],
        ngroups: int,
        starts: npt.NDArray[np.int64],
        ends: npt.NDArray[np.int64],
    ) -> ArrayLike:
        from pandas.core.arrays.string_ import StringDtype

        if isinstance(self.dtype, StringDtype):
            raise TypeError(
                f"dtype '{self.dtype}' does not support operation 'quantile'"
            )

        values = self._to_groupby_compatible()
        result = values._groupby_quantile(
            qs=qs,
            interpolation=interpolation,
            ids=ids,
            ngroups=ngroups,
            starts=starts,
            ends=ends,
        )
        return self._groupby_result_to_arrow(result)

    def _apply_elementwise(self, func: Callable) -> list[list[Any]]:
        """Apply a callable to each element while maintaining the chunking structure."""
        return [
            [

View on GitHub (pinned to 3b7651241d)