pola-rs/polars · error
activate 'propagate_nans' feature
Error message
activate 'propagate_nans' feature
What it means
In aggregation expression evaluation, GroupByMethod::NanMin (NaN-skipping minimum) is only compiled when the `propagate_nans` feature is enabled. Without it, selecting nan_min in a group_by aggregation panics at evaluation time.
Solutions
- Enable the feature: polars = { ..., features = ["propagate_nans"] }
- Use plain min() aggregation if NaN-skipping semantics are not required
- Filter NaNs manually before aggregating: col("x").filter(col("x").is_not_nan()).min() inside agg context
Example fix
// before
polars = { version = "0.46", features = ["lazy"] }
// after
polars = { version = "0.46", features = ["lazy", "propagate_nans"] } Defensive patterns
Strategy: validation
Validate before calling
fn agg_supported(m: GroupByMethod) -> bool {
!matches!(m, GroupByMethod::NanMin | GroupByMethod::NanMax) // unless propagate_nans enabled
} Prevention
- Enable propagate_nans whenever aggregations may reference nan_min/nan_max
- Validate user-built aggregation expressions against compiled features
- Prefer min/max plus explicit is_not_nan filters for portability
When it happens
Trigger: Using an aggregation expression like col("x").nan_min() (GroupByMethod::NanMin) inside group_by/agg on a build without the `propagate_nans` feature.
Common situations: Default polars builds (propagate_nans is opt-in); notebooks or libraries built with reduced features; copying examples that use nan_min without adding the feature.
Related errors
- activate ' ' feature
- activate feature dtype-duration
- activate 'round_series' feature
- activate the 'dtype-struct' feature to handle struct data…
- activate the 'object' feature to be able to load…
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/4d5f1a618598b05a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-expr/src/expressions/aggregation.rs:90
s,
allow_threading,
),
},
#[cfg(feature = "propagate_nans")]
GroupByMethod::NanMin => parallel_op_columns(
|s| {
Ok(polars_ops::prelude::nan_propagating_aggregate::nan_min_s(
s.as_materialized_series(),
s.name().clone(),
)
.into_column())
},
s,
allow_threading,
),
#[cfg(not(feature = "propagate_nans"))]
GroupByMethod::NanMin => {
panic!("activate 'propagate_nans' feature")
},
GroupByMethod::Max => match s.is_sorted_flag() {
IsSorted::Ascending | IsSorted::Descending => {
s.max_reduce().map(|sc| sc.into_column(s.name().clone()))
},
IsSorted::Not => parallel_op_columns(
|s| s.max_reduce().map(|sc| sc.into_column(s.name().clone())),
s,
allow_threading,
),
},
#[cfg(feature = "propagate_nans")]
GroupByMethod::NanMax => parallel_op_columns(
|s| {
Ok(polars_ops::prelude::nan_propagating_aggregate::nan_max_s(
s.as_materialized_series(),
s.name().clone(),
)View on GitHub (pinned to fe841f959e)