Skip to main content

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

new GroupByBuilder()

new GroupByBuilder(dart): GroupByBuilder

Parameters

ParameterType
dartany

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:152

Properties

PropertyModifierType
dartprivateany

Methods

add()

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

Adds an aggregation to the query.

Parameters

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:171


aggregate()

aggregate(options?): DataFrame

Performs the aggregation

Parameters

ParameterType
options?object
options.autoName?boolean

Returns

DataFrame

Source

src/dataframe/stats.ts:158


avg()

avg(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:274


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

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:199


first()

first(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:328


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

Source

src/dataframe/stats.ts:334


key()

key(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:181


max()

max(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:247


med()

med(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:265


min()

min(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:238


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

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:219


pivot()

pivot(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:190


q1()

q1(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:301


q2()

q2(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:310


q3()

q3(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:319


stdev()

stdev(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:283


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

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

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:256


toString()

toString(): string

Returns

string

Source

src/dataframe/stats.ts:357


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

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:209


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

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

Returns

GroupByBuilder

  • this for chaining

Source

src/dataframe/stats.ts:229


variance()

variance(srcColName, resultColName?): GroupByBuilder

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

Parameters

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

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:292


where()

where(pattern): GroupByBuilder

Specifies the filter for the source rows.

Parameters

ParameterType
patternstring | object

Returns

GroupByBuilder

Input

pattern

Source

src/dataframe/stats.ts:343


whereRowMask()

whereRowMask(bitset): GroupByBuilder

Parameters

ParameterType
bitsetBitSet

Returns

GroupByBuilder

Source

src/dataframe/stats.ts:350