pola-rs/polars · error

dtype {:?} not supported

Error message

dtype {:?} not supported

What it means

Fallback arm of the python method-dispatch macro: the series dtype is not any of the supported variants (numeric, string, categorical, object, ...), so the requested method cannot be dispatched on it. The message names the unsupported dtype; convert the series first.

Source

Thrown at crates/polars-python/src/utils.rs:68

                CategoricalPhysical::U8 => $self.cat8().unwrap().$method($($args),*),
                CategoricalPhysical::U16 => $self.cat16().unwrap().$method($($args),*),
                CategoricalPhysical::U32 => $self.cat32().unwrap().$method($($args),*),
            },

            #[cfg(feature = "object")]
            DataType::Object(_) => {
                $self
                .as_any()
                .downcast_ref::<ObjectChunked<ObjectValue>>()
                .unwrap()
                .$method($($args),*)
            },
            DataType::Map(_, _) => $self.map().unwrap().$method($($args),*),
            DataType::Extension(_, _) => $self.ext().unwrap().$method($($args),*),

            DataType::Null => $self.null().unwrap().$method($($args),*),

            dt @ (DataType::BinaryOffset | DataType::Unknown(_)) => panic!("dtype {:?} not supported", dt)
        }
    }
}

/// Boilerplate for `|e| PyPolarsErr::from(e).into()`
#[allow(unused)]
pub(crate) fn to_py_err<E: Into<PyPolarsErr>>(e: E) -> PyErr {
    e.into().into()
}

pub trait EnterPolarsExt {
    /// Whenever you have a block of code in the public Python API that
    /// (potentially) takes a long time, wrap it in enter_polars. This will
    /// ensure we release the GIL and catch KeyboardInterrupts.
    ///
    /// This not only can increase performance and usability, it can avoid
    /// deadlocks on the GIL for Python UDFs.
    fn enter_polars<T, E, F>(self, f: F) -> PyResult<T>

View on GitHub (pinned to 68506541d2)

Solutions

  1. Convert the value to a supported dtype before passing it across the Python/Rust boundary; check the dtype with s.dtype.

Example fix

s = s.cast(pl.Int64)  # use a supported dtype
Defensive patterns

Strategy: fallback

When it happens

Trigger: Passing a value of an unsupported dtype into a Polars conversion utility.

Common situations: See trigger scenarios.


AI-assisted analysis of pola-rs/polars@68506541d2 (2026-08-19). Data as JSON: /api/errors/20b1c01c6b3dd1cd. Report an issue: GitHub.