GroupByBuilder
Namespace: Polars.CSharp
Unified builder for DataFrame GroupBy operations (Standard, Dynamic, Rolling)
Instance Methods
Agg
Aggregate with specified expressions. Under the hood, this routes through the Lazy engine to maximize performance and optimizations.
public DataFrame Agg(params Expr[] aggs)Parameters
| Name | Type | Description |
|---|---|---|
aggs | Expr[] | Aggregation expressions |
Returns: A new aggregated DataFrame
All
Aggregate all columns into lists.
public DataFrame All()Count
Count the number of values in each group.
public DataFrame Count()First
Aggregate the first values in the group.
public DataFrame First(bool ignoreNulls = false)Parameters
| Name | Type | Description |
|---|---|---|
ignoreNulls | bool | Ignore null values (default False). If set to True, the first non-null value for each aggregation is returned, otherwise None is returned if no non-null value exists. |
GetEnumerator
Allows iteration over the groups of the group by operation.
public IEnumerator<(object[], DataFrame)> GetEnumerator()GetGroups
Allows iteration over the groups of the group by operation.(Strong Typed)
public IEnumerable<(TKey, DataFrame)> GetGroups<TKey>()Having
Filter groups with a predicate after aggregation.
public GroupByBuilder Having(Expr predicate)Parameters
| Name | Type | Description |
|---|---|---|
predicate | Expr | - |
Head
public DataFrame Head(int n = 10)Parameters
| Name | Type | Description |
|---|---|---|
n | int | - |
Last
Aggregate the last values in the group.
public DataFrame Last(bool ignoreNulls = false)Parameters
| Name | Type | Description |
|---|---|---|
ignoreNulls | bool | Ignore null values (default False). If set to True, the last non-null value for each aggregation is returned, otherwise None is returned if no non-null value exists. |
Len
Return the number of rows in each group.
public DataFrame Len(string name = "len")Parameters
| Name | Type | Description |
|---|---|---|
name | string | Assign a name to the resulting column; if unset, defaults to “len”. |
Max
Reduce the groups to the maximal value.
public DataFrame Max()Mean
Reduce the groups to the mean value.
public DataFrame Mean()Median
Reduce the groups to the median value.
public DataFrame Median()Min
Reduce the groups to the minimal value.
public DataFrame Min()NUnique
Count the unique values per group.
public DataFrame NUnique()Quantile
Compute the quantile per group.
public DataFrame Quantile(double quantile, QuantileMethod interpolation = QuantileMethod.Linear)Parameters
| Name | Type | Description |
|---|---|---|
quantile | double | Quantile between 0.0 and 1.0. |
interpolation | QuantileMethod | Interpolation method. |
Sum
Reduce the groups to the sum.
public DataFrame Sum()Tail
public DataFrame Tail(int n = 10)Parameters
| Name | Type | Description |
|---|---|---|
n | int | - |