namespaces.EraExpr
era_pl.namespaces.EraExpr(expr)Custom expression helpers used throughout the Polars-facing API.
Methods
| Name | Description |
|---|---|
| div_if_pos | Divide by other only when the denominator is strictly positive. |
| ntile | Assign observations to n approximately equal-sized buckets. |
| truncate | Set values outside type-2 quantile cutoffs to null. |
| winsorize | Clip values to type-2 quantile cutoffs, following farr::winsorize(). |
div_if_pos
era_pl.namespaces.EraExpr.div_if_pos(other)Divide by other only when the denominator is strictly positive.
The result is null when the denominator is zero, negative, or null. This is convenient for ratio construction in accounting-style pipelines where non-positive denominators are usually treated as invalid.
ntile
era_pl.namespaces.EraExpr.ntile(n)Assign observations to n approximately equal-sized buckets.
This mirrors the common SQL/R ntile idea and is typically used with .over(...) to create within-group deciles, quintiles, and similar ranked portfolios. Null values remain null and are excluded when bucket sizes are calculated.
truncate
era_pl.namespaces.EraExpr.truncate(prob=0.01, p_low=None, p_high=None)Set values outside type-2 quantile cutoffs to null.
Argument resolution matches :meth:winsorize.
winsorize
era_pl.namespaces.EraExpr.winsorize(prob=0.01, p_low=None, p_high=None)Clip values to type-2 quantile cutoffs, following farr::winsorize().
Argument handling mirrors the R helper:
winsorize(prob=0.01)is equivalent towinsorize(p_low=0.01, p_high=0.99).- If
p_lowand/orp_highare supplied, those explicit cutoffs are used in preference to the defaults implied byprob. - If
prob=None, only the explicitly supplied side(s) are applied, so one-sided winsorization is possible.