{"record":{"id":"a89409fcc039390c","repo":"pola-rs/polars","slug":"activate-propagate-nans","errorCode":null,"errorMessage":"activate 'propagate_nans'","messagePattern":"activate 'propagate_nans'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-python/src/functions/lazy.rs","lineNumber":586,"sourceCode":"    let mut value = value.inner;\n    let n = n.inner;\n\n    if let Some(dtype) = dtype {\n        value = value.cast(dtype.0);\n    }\n\n    dsl::repeat(value, n).into()\n}\n\n#[pyfunction]\npub fn spearman_rank_corr(a: PyExpr, b: PyExpr, propagate_nans: bool) -> PyExpr {\n    #[cfg(feature = \"propagate_nans\")]\n    {\n        dsl::spearman_rank_corr(a.inner, b.inner, propagate_nans).into()\n    }\n    #[cfg(not(feature = \"propagate_nans\"))]\n    {\n        panic!(\"activate 'propagate_nans'\")\n    }\n}\n\n#[pyfunction]\n#[cfg(feature = \"sql\")]\npub fn sql_expr(sql: &str) -> PyResult<PyExpr> {\n    let expr = polars::sql::sql_expr(sql).map_err(PyPolarsErr::from)?;\n    Ok(expr.into())\n}\n","sourceCodeStart":568,"sourceCodeEnd":596,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-python/src/functions/lazy.rs#L568-L596","documentation":"This panic is raised by spearman_rank_corr when the polars Python package was compiled without the 'propagate_nans' feature enabled. The Rust binding only contains the real implementation behind #[cfg(feature = \"propagate_nans\")]; without it, the function unconditionally panics with a directive telling the user to activate the feature.","triggerScenarios":"Calling pl.spearman_rank_corr (or the corresponding expression function) on a polars build installed without the propagate_nans cargo feature.","commonSituations":"Using a minimal/custom-compiled polars build (e.g. from source with a reduced feature set) or an environment where the binary was built without this feature; more common when building polars from source or using alternative distribution channels.","solutions":["Install the official polars wheel from PyPI, which includes this feature.","If building from source, rebuild with the propagate_nans feature enabled (cargo build with --features propagate_nans or the 'all-features' option).","As a workaround, compute Spearman correlation via rank + pearson corr: pl.corr(a.rank(), b.rank(), method='pearson')."],"exampleFix":"# before (custom build without feature)\ndf.select(pl.corr('a', 'b', method='spearman', propagate_nans=True))\n# after: rank-then-pearson workaround, or reinstall official wheel\npip install --upgrade --force-reinstall polars\ndf.select(pl.corr('a', 'b', method='pearson').fill_nan(None))  # after manual rank","handlingStrategy":"validation","validationCode":"import polars as pl\nassert 'propagate_nans' in getattr(pl, '_features', getattr(pl.build_info(), 'features', [])) if hasattr(pl, 'build_info') else True\n# or feature-check at runtime:\nimport polars; assert 'propagate_nans' in str(polars.build_info()), 'propagate_nans feature required'","typeGuard":"def supports_propagate_nans():\n    import polars\n    try:\n        return 'propagate_nans' in polars.build_info()['features']\n    except Exception:\n        return True","tryCatchPattern":"try:\n    corr = pl.corr('a', 'b', method='spearman', propagate_nans=True)\nexcept BaseException as e:\n    if 'propagate_nans' in str(e):\n        corr = pl.corr(pl.col('a').rank(), pl.col('b').rank(), method='pearson')\n    else:\n        raise","preventionTips":["Prefer official PyPI wheels over custom builds.","Record required cargo features in your build scripts.","Pin polars versions in deployment environments."],"tags":["rust","feature-flag","compile-time","statistics"],"backgroundTag":"feature-not-enabled","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}