DataFramePivotCountsCommonDocs

Computes a count matrix (similar to frequency encoding) for the values in the specified columns of this DataFrame, returning a new DataFrame where:

  • Columns represent all unique values from the selected columns (they become column groups corresponding to value combinations when using then, similar to pivot);

  • Rows correspond to all unique combinations of values from the remaining columns; each combination is represented in dedicated key columns that store a distinct set of values for each row (similar to keys in GroupBy).

  • Cells contain an Int value indicating how many rows with the corresponding combination of values (horizontal and vertical) exist in the DataFrame.

This function combines pivot, groupByOther, and count operations into a single call.

This can include column groups and nested columns.

See Selecting Columns.

For more information: See pivotCounts on the documentation website.

See also: pivotMatches, which performs a similar operation but checks if there is any matching row instead of counting them to produce a Boolean matrix.

This pivotCounts Overload