Skip to main content

Class: GroupByBuilder

dg.GroupByBuilder

Fluid API for building an aggregation query against a DataFrame. Build a query by calling the following methods: key, pivot, count, uniqueCount, missingValueCount, valueCount, min, max, sum, avg, stdev, variance, q1, q2, q3.

When the query is constructed, execute it by calling aggregate, which will produce a DataFrame.

See samples: https://public.datagrok.ai/js/samples/data-frame/aggregation

Example

let avgAgesByRaceAndSex = demographicsTable
.groupBy(['race', 'sex'])
.avg('age')
.aggregate();

Constructors

constructor

new GroupByBuilder(dart)

Parameters

NameType
dartany

Defined in

src/dataframe.ts:1915

Properties

dart

Private Readonly dart: any

Defined in

src/dataframe.ts:1913

Methods

add

add(agg, colName?, resultColName?): GroupByBuilder

Performs the aggregation

Parameters

NameTypeDescription
agg"values" | "max" | "key" | "first" | "count" | "unique" | "nulls" | "min" | "sum" | "med" | "avg" | "stdev" | "variance" | "skew" | "kurt" | "q1" | "q2" | "q3" | "pivot" | "#selected"Aggregation type.
colName?null | stringColumn name.
resultColName?null | stringName of the resulting column. Default value is agg(colName).

Returns

GroupByBuilder

Defined in

src/dataframe.ts:1932


aggregate

aggregate(): DataFrame

Performs the aggregation

Returns

DataFrame

Defined in

src/dataframe.ts:1921


avg

avg(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates average value for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2035


count

count(resultColName?): GroupByBuilder

Adds an aggregation that counts rows, including these will null values. See also count, valueCount, uniqueCount, missingValueCount Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
resultColName?string'count'column name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:1960


first

first(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that takes first value for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2089


getGroups

getGroups(): Map<string, DataFrame>

Gets groups of DataFrames

Returns

Map<string, DataFrame>

  • where keys are stings in format 'columnName=value' and values are DataFrames

Defined in

src/dataframe.ts:2095


key

key(srcColName, resultColName?): GroupByBuilder

Adds a key column to group values on. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:1942


max

max(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates maximum value for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2008


med

med(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates median value for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2026


min

min(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates minimum value for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:1999


missingValueCount

missingValueCount(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that counts number of missing values in the specified column. See also count, valueCount, uniqueCount, missingValueCount Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:1980


pivot

pivot(srcColName, resultColName?): GroupByBuilder

Adds a column to pivot values on. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:1951


q1

q1(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates first quartile for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2062


q2

q2(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates second quartile for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2071


q3

q3(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates third quartile for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2080


stdev

stdev(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates standard deviation for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2044


sum

sum(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates sum of the values for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2017


toString

toString(): string

Returns

string

Defined in

src/dataframe.ts:2119


uniqueCount

uniqueCount(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that counts number of unique values in the specified column. See also count, valueCount, missingValueCount Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:1970


valueCount

valueCount(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that counts rows, including these will null values. See also count, valueCount, uniqueCount, missingValueCount Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:1990


variance

variance(srcColName, resultColName?): GroupByBuilder

Adds an aggregation that calculates varians for the specified column. Call aggregate when the query is constructed.

Parameters

NameTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?null | stringnullcolumn name in the resulting DataFrame

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2053


where

where(pattern): GroupByBuilder

Specifies the filter for the source rows.

Input

pattern

Parameters

NameType
patternstring | object

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2104


whereRowMask

whereRowMask(bitset): GroupByBuilder

Parameters

NameType
bitsetBitSet

Returns

GroupByBuilder

Defined in

src/dataframe.ts:2112