Skip to main content

GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:182

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/aggregate

Example​

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

Constructors​

Constructor​

new GroupByBuilder(dart): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:185

Parameters​

ParameterType
dartany

Returns​

GroupByBuilder

Methods​

add()​

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

Defined in: js-api/src/dataframe/stats.ts:202

Adds an aggregation to the query.

Parameters​

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

Returns​

GroupByBuilder

this for chaining


aggregate()​

aggregate(options?): DataFrame

Defined in: js-api/src/dataframe/stats.ts:190

Performs the aggregation

Parameters​

ParameterType
options?{ autoName?: boolean; }
options.autoName?boolean

Returns​

DataFrame


avg()​

avg(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:303

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder


count()​

count(resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:230

Adds an aggregation that counts rows, including those with null values. See also 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


first()​

first(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:351

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder


getGroups()​

getGroups(): object

Defined in: js-api/src/dataframe/stats.ts:356

Gets groups of DataFrames as a plain object keyed by 'columnName=value' strings.

Returns​

object


key()​

key(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:212

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder

this for chaining


max()​

max(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:278

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder

this for chaining


med()​

med(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:295

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder

this for chaining


min()​

min(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:269

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder

this for chaining


missingValueCount()​

missingValueCount(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:250

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder

this for chaining


pivot()​

pivot(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:221

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

Parameters​

ParameterTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder

this for chaining


q1()​

q1(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:327

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder


q2()​

q2(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:335

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder


q3()​

q3(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:343

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder


stdev()​

stdev(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:311

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder


sum()​

sum(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:286

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder


toString()​

toString(): string

Defined in: js-api/src/dataframe/stats.ts:377

Returns​

string


uniqueCount()​

uniqueCount(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:240

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?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder

this for chaining


valueCount()​

valueCount(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:260

Adds an aggregation that counts non-null values in the specified column. See also count, uniqueCount, missingValueCount Call aggregate when the query is constructed.

Parameters​

ParameterTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder

this for chaining


variance()​

variance(srcColName, resultColName?): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:319

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

Parameters​

ParameterTypeDefault valueDescription
srcColNamestringundefinedcolumn name in the source table
resultColName?string | nullnullcolumn name in the resulting DataFrame

Returns​

GroupByBuilder


where()​

where(pattern): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:363

Specifies the filter for the source rows.

Parameters​

ParameterType
patternstring | object

Returns​

GroupByBuilder

Input​

pattern


whereRowMask()​

whereRowMask(bitset): GroupByBuilder

Defined in: js-api/src/dataframe/stats.ts:370

Parameters​

ParameterType
bitsetBitSet

Returns​

GroupByBuilder