snowflake.snowpark.DataFrame.group_by¶
- DataFrame.group_by(*cols: Union[Column, str, Iterable[Union[Column, str]]]) RelationalGroupedDataFrame[source]¶
Groups rows by the columns specified by expressions (similar to GROUP BY in SQL).
This method returns a
RelationalGroupedDataFramethat you can use to perform aggregations on each group of data.With no columns (
df.group_by()ordf.group_by([])), the entire DataFrame forms one group for aggregation. With one or more columns, rows that have the same values for those columns form a group. Calling this method defines the groups; call an aggregation method such asRelationalGroupedDataFrame.agg()to produce a result DataFrame.- Parameters:
*cols – Column names or expressions that define the groups. Omit this argument or pass an empty list to aggregate all rows together.
Valid inputs are:
Examples