dataFrame.column.stat — reduceCategories()

Description

The reduceCategories() method of the stat object returns a category mask in which infrequent categories are grouped into a single category.

Signature

dataFrame.column(columnName).stat.reduceCategories({ groupLabel: 'Other', coverage: 0.9, minCount: 2 })
Scope
column
Family
stat
Returns
mask

Argument

columnName (string)
The name of the column from which to compute the coefficient of variation.
options (object)
Category reduction options.

Options

groupLabel (string)
The label assigned to grouped categories. (Default: Other.)
coverage (number)
The minimum cumulative frequency coverage to preserve before grouping remaining categories. (Default: 0.9.)
minCount (number)
The minimum frequency required for a category to be preserved. (Default: 2.)

Returns

mask (array)
An array containing the reduced category assigned to each value.

Example

// reduce the category of the values of a column of the dataFrame
var mask = dataFrame.column('revenue').stat.reduceCategories();

// add the new categorical values into the dataFrame
dataFrame.column('newValues').set(mask);