GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:148
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:151
Parameters
| Parameter | Type |
|---|---|
dart | any |
Returns
GroupByBuilder
Methods
add()
add(
agg,colName?,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:168
Adds an aggregation to the query.
Parameters
| Parameter | Type | Description |
|---|---|---|
agg | "values" | "max" | "key" | "min" | "sum" | "pivot" | "first" | "count" | "unique" | "nulls" | "med" | "avg" | "stdev" | "variance" | "skew" | "kurt" | "q1" | "q2" | "q3" | "#selected" | Aggregation type. |
colName? | string | null | Column name. |
resultColName? | string | null | Name 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:156
Performs the aggregation
Parameters
| Parameter | Type |
|---|---|
options? | { autoName?: boolean; } |
options.autoName? | boolean |
Returns
avg()
avg(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:269
Adds an aggregation that calculates average value for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
count()
count(
resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:196
Adds an aggregation that counts rows, including those with null values. See also valueCount, uniqueCount, missingValueCount Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
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:317
Adds an aggregation that takes first value for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
getGroups()
getGroups():
object
Defined in: js-api/src/dataframe/stats.ts:322
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:178
Adds a key column to group values on. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
this for chaining
max()
max(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:244
Adds an aggregation that calculates maximum value for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
this for chaining
med()
med(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:261
Adds an aggregation that calculates median value for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
this for chaining
min()
min(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:235
Adds an aggregation that calculates minimum value for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
this for chaining
missingValueCount()
missingValueCount(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:216
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
this for chaining
pivot()
pivot(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:187
Adds a column to pivot values on. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
this for chaining
q1()
q1(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:293
Adds an aggregation that calculates first quartile for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
q2()
q2(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:301
Adds an aggregation that calculates second quartile for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
q3()
q3(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:309
Adds an aggregation that calculates third quartile for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
stdev()
stdev(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:277
Adds an aggregation that calculates standard deviation for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
sum()
sum(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:252
Adds an aggregation that calculates sum of the values for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
toString()
toString():
string
Defined in: js-api/src/dataframe/stats.ts:343
Returns
string
uniqueCount()
uniqueCount(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:206
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
this for chaining
valueCount()
valueCount(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:226
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
this for chaining
variance()
variance(
srcColName,resultColName?):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:285
Adds an aggregation that calculates variance for the specified column. Call aggregate when the query is constructed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
srcColName | string | undefined | column name in the source table |
resultColName? | string | null | null | column name in the resulting DataFrame |
Returns
GroupByBuilder
where()
where(
pattern):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:329
Specifies the filter for the source rows.
Parameters
| Parameter | Type |
|---|---|
pattern | string | object |
Returns
GroupByBuilder
Input
pattern
whereRowMask()
whereRowMask(
bitset):GroupByBuilder
Defined in: js-api/src/dataframe/stats.ts:336
Parameters
| Parameter | Type |
|---|---|
bitset | BitSet |
Returns
GroupByBuilder