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 groupscorresponding to value combinations when usingthen, similar topivot);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
keysinGroupBy).Cells contain an
Intvalue indicating how many rows with the corresponding combination of values (horizontal and vertical) exist in theDataFrame.
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.