Skip to content

Commit

Permalink
fix skew autoexplode and add test (#3251)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvanheerden committed Apr 28, 2022
1 parent 4d02a46 commit d34d2c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion polars/polars-lazy/src/dsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,11 @@ impl Expr {
move |s| s.skew(bias).map(|opt_v| Series::new(s.name(), &[opt_v])),
GetOutput::from_type(DataType::Float64),
)
.with_fmt("skew")
.with_function_options(|mut options| {
options.fmt_str = "skew";
options.auto_explode = true;
options
})
}

#[cfg(feature = "moment")]
Expand Down
20 changes: 20 additions & 0 deletions polars/polars-lazy/src/tests/aggregations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@ fn test_cumsum_agg_as_key() -> Result<()> {
Ok(())
}

#[test]
fn test_auto_explode() -> Result<()> {
let df = fruits_cars();

let out = df
.clone()
.lazy()
.groupby([col("fruits")])
.agg([
col("B").skew(false).alias("bskew"),
col("B").kurtosis(false, false).alias("bkurt"),
])
.collect()?;

assert!(matches!(out.column("bskew")?.dtype(), DataType::Float64));
assert!(matches!(out.column("bkurt")?.dtype(), DataType::Float64));

Ok(())
}

#[test]
fn test_auto_list_agg() -> Result<()> {
let df = fruits_cars();
Expand Down

0 comments on commit d34d2c2

Please sign in to comment.