ungroup¶
- pydiverse.transform.ungroup() Pipeable[source]¶
Clear the grouping state of the table.
Examples
In the following example,
group_byandungroupare used to specify that each aggregation function between them uses the columnt.cfor grouping.>>> t = pdt.Table( ... { ... "a": [1.2, 5.077, -2.29, -0.0, 3.0, -7.7], ... "b": ["a ", "transform", "pipedag", "cdegh", " -ade ", " pq"], ... "c": [True, False, None, None, True, True], ... "d": [4, 4, 2, 0, 1, 0], ... } ... ) >>> ( ... t ... >> group_by(t.c) ... >> mutate( ... u=t.b.str.len().max() + t.a.min(), ... v=t.d.mean(filter=t.a >= 0), ... ) ... >> ungroup() ... >> show() ... ) shape: (6, 6) ┌───────┬───────────┬───────┬─────┬────────┬─────┐ │ a ┆ b ┆ c ┆ d ┆ u ┆ v │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ f64 ┆ str ┆ bool ┆ i64 ┆ f64 ┆ f64 │ ╞═══════╪═══════════╪═══════╪═════╪════════╪═════╡ │ 1.2 ┆ a ┆ true ┆ 4 ┆ -0.7 ┆ 2.5 │ │ 5.077 ┆ transform ┆ false ┆ 4 ┆ 14.077 ┆ 4.0 │ │ -2.29 ┆ pipedag ┆ null ┆ 2 ┆ 4.71 ┆ 0.0 │ │ -0.0 ┆ cdegh ┆ null ┆ 0 ┆ 4.71 ┆ 0.0 │ │ 3.0 ┆ -ade ┆ true ┆ 1 ┆ -0.7 ┆ 2.5 │ │ -7.7 ┆ pq ┆ true ┆ 0 ┆ -0.7 ┆ 2.5 │ └───────┴───────────┴───────┴─────┴────────┴─────┘