group_by
dataframeGroups a DataFrame by one or more columns
Syntax
group_by(dataframe, column) Parameters
dataframe (dataframe) The DataFrame to group
column (string) The column name or expression to group by
Returns
array Array of grouped DataFrames
Examples
Group DataFrame by department
Input:
group_by(.department) Output:
Groups rows by department column Group by department and count rows in each group
Input:
group_by(.department) | map({dept: .[0].department, count: length}) Output:
Array of objects with department and count The group_by() function groups a DataFrame by one or more columns, returning an array where each element contains the rows for a specific group.
Usage
Use group_by() to aggregate data by categories, calculate group statistics, or prepare data for reporting. Combine with map() and aggregation functions to compute summaries for each group.