Group By
Group and aggregate the data.
Group and aggregate the data
Parameters
| Name | Description | Accepted Values | Default | Required |
|---|---|---|---|---|
| I/O | ||||
by | List of the input columns to group on. | string, array | [] | No |
| Options | ||||
list | Group and return all values for these column(s) as a list. | string, array | — | No |
first | The first value for these column(s). | string, array | — | No |
last | The last value for these column(s). | string, array | — | No |
min | The minimum value for these column(s). | string, array | — | No |
max | The maximum value for these column(s). | string, array | — | No |
mean | The mean (average) value for these column(s). | string, array | — | No |
median | The median value for these column(s). | string, array | — | No |
nunique | The count of unique values for these column(s). | string, array | — | No |
count | The count of values for these column(s). | string, array | — | No |
counts | Return a dictionary containing the count of each distinct value for these column(s). Keys are converted to JSON-safe strings; missing values use the key "null" and booleans use lowercase "true"/"false". | string, array | — | No |
std | The standard deviation of values for these column(s). | string, array | — | No |
sum | The total of values for these column(s). | string, array | — | No |
any | Return true if any of the values for these column(s) are true. | string, array | — | No |
all | Return true if all of the values for these column(s) are true. | string, array | — | No |
p75 | Get a percentile. Note, you can use any integer here for the corresponding percentile. | string, array | — | No |
custom.* | Placeholder for custom functions. Replace 'placeholder' with the name of the function. | string, array | — | No |
| Formatting | ||||
auto_rename_columns | If true (default), aggregated column names include the operation as a suffix (e.g. Value.sum). If false, column names are left as-is; use a dictionary entry to supply a custom output name (e.g. - Value: Total). | boolean | true | No |
| Conditions | ||||
if | Condition that determines whether the wrangle runs as a whole. Recipe variables may be referenced with ${variable}. | string | — | No |
where | Filter rows before applying the wrangle using SQL-like criteria, such as column1 = 123 OR column2 = 'abc'. | string | — | No |
where_params | Values used with where for parameterized criteria. Uses SQLite placeholder syntax such as ? or :name. | array, object | — | No |
Examples
wrangles:
- select.group_by:
by:
- Product Type
sum: Quantity
mean: Price ($)
| Product | Quantity | Price ($) | Product Type |
|---|---|---|---|
| Hammer | 3 | 12.99 | Hand Tools |
| Ratchet Wrench | 12 | 6.99 | Hand Tools |
| Cordless Drill | 2 | 49.99 | Power Tools |
| Reciprocating Saw | 7 | 29.99 | Power Tools |
| Product Type | Quantity.sum | Price ($).mean |
|---|---|---|
| Hand Tools | 15 | 9.99 |
| Power Tools | 9 | 39.99 |
wrangles:
- select.group_by:
by: Category
custom.sum_times_two: Quantity
| Category | Quantity |
|---|---|
| Hand Tools | 3 |
| Hand Tools | 1 |
| Hand Tools | 2 |
| Power Tools | 4 |
| Category | Quantity.sum_times_two |
|---|---|
| Hand Tools | 12 |
| Power Tools | 4 |
Access
| Requirement | Value |
|---|---|
| AI-powered | No |
| Requires WrangleWorks account | No |
| Requires subscription | No |
| Requires external API key | No |
Technical details
| Field | Value |
|---|---|
| Catalog ID | 52 |
| Catalog key | select.group_by |
| Recipe key | select.group_by |
| Catalog status | active |
| Lifecycle status | active |
| Recipe Writer eligible | Yes |
| Namespace | select |
| Documentation group | select |
| Aliases | None |
| Runtime symbol | wrangles.recipe_wrangles.select.group_by |
| Legacy UUID | c0af10b1-423a-416c-8cb5-7e7fe1164964 |
Sources