pola-rs/polars · error

activate 'product' feature

Error message

activate 'product' feature

What it means

Series::prod_reduce handles integer/float reductions, but if the compiled build lacks the relevant product support for the series' dtype (feature-gated arms like dtype-decimal / product feature absent) it reaches the panic telling you to rebuild polars with the 'product' feature enabled. It is a build-configuration error, not a data error.

Source

Thrown at crates/polars-core/src/series/mod.rs:901

                UInt64 => Ok(self.u64().unwrap().prod_reduce()),
                #[cfg(feature = "dtype-i128")]
                Int128 => Ok(self.i128().unwrap().prod_reduce()),
                #[cfg(feature = "dtype-u128")]
                UInt128 => Ok(self.u128().unwrap().prod_reduce()),
                #[cfg(feature = "dtype-f16")]
                Float16 => Ok(self.f16().unwrap().prod_reduce()),
                Float32 => Ok(self.f32().unwrap().prod_reduce()),
                Float64 => Ok(self.f64().unwrap().prod_reduce()),
                #[cfg(feature = "dtype-decimal")]
                Decimal(..) => Ok(self.decimal().unwrap().prod_reduce()),
                dt => {
                    polars_bail!(InvalidOperation: "`product` operation not supported for dtype `{dt}`")
                },
            }
        }
        #[cfg(not(feature = "product"))]
        {
            panic!("activate 'product' feature")
        }
    }

    /// Cast throws an error if conversion had overflows
    pub fn strict_cast(&self, dtype: &DataType) -> PolarsResult<Series> {
        self.cast_with_options(dtype, CastOptions::Strict)
    }

    #[cfg(feature = "dtype-decimal")]
    pub fn into_decimal(self, precision: usize, scale: usize) -> PolarsResult<Series> {
        match self.dtype() {
            DataType::Int128 => Ok(self
                .i128()
                .unwrap()
                .clone()
                .into_decimal(precision, scale)?
                .into_series()),
            DataType::Decimal(cur_prec, cur_scale)

View on GitHub (pinned to 68506541d2)

Solutions

  1. Enable the `product` cargo feature to use product aggregation.
  2. Compute the product manually via `exp(sum(log(x)))` on positive values as a workaround.
Defensive patterns

Strategy: fallback

When it happens

Trigger: This panic/expect fires when execution reaches an unguarded state described by: "activate 'product' feature". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.

Common situations: Encountered when input data or configuration does not meet the preconditions of the throwing code path ("activate 'product' feature"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.


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