countDistinct
Returns the number of distinct rows in this DataFrame.
Compares rows based on the values in all columns and returns the number of unique row combinations.
See also:
distinct, which removes duplicate rows and returns a newDataFrame.count, which counts the number of rows satisfying a given predicate.
For more information: See countDistinct on the documentation website.
Return
The number of distinct rows in this DataFrame.
Returns the number of distinct combinations of values in selected columns in this DataFrame.
Compares values in the selected columns and returns the number of unique values combinations.
See also:
distinct, which removes duplicate rows and returns a newDataFrame.count, which counts the number of rows satisfying a given predicate.
For more information: See countDistinct on the documentation website.
This countDistinct overload
Select or express columns using the Columns Selection DSL.
This DSL is initiated by a Columns Selector lambda, which operates in the context of the Columns Selection DSL and expects you to return a SingleColumn or ColumnSet (so, a ColumnsResolver). This is an entity formed by calling any (combination) of the functions in the DSL that is or can be resolved into one or more columns.
The Columns Selection DSL allows using Extension Properties for specifying columns type- and name-safe.
Check out: Columns Selection DSL Grammar
See Column Selectors on the documentation website.
Example
// Counts unique combinations of values in the "year" and "title" columns
// across all rows in the DataFrame
df.countDistinct { year and title }Return
The number of distinct rows in this DataFrame.
Returns the number of distinct combinations of values in selected columns in this DataFrame.
Compares values in the selected columns and returns the number of unique values combinations.
See also:
distinct, which removes duplicate rows and returns a newDataFrame.count, which counts the number of rows satisfying a given predicate.
For more information: See countDistinct on the documentation website.
This countDistinct overload
Select single or multiple columns using their names as Strings. (String API).
Example
// Counts unique combinations of values in the "year" and "title" columns
// across all rows in the DataFrame
df.countDistinct("year", "title")Return
The number of distinct rows in this DataFrame.
Aggregates this GroupBy by counting the number of distinct rows in each group.
Compares rows in each group based on the values in all columns. Returns a new DataFrame where each row corresponds to a group. The resulting DataFrame contains:
the original group key columns,
a new column (named resultName, default is
"countDistinct") that contains the number of distinct rows in each group.
See also:
aggregate, which aggregates aGroupByusing the provided statistics.count, which counts the number of rows in each group.distinct, which removes duplicate rows and returns a newDataFrame.groupBy, which groups the rows of aDataFramebased on the values in one or more specified cols.
For more information: See countDistinct on the documentation website.
Example
// Counts the number of distinct rows for each city, returning
// a new DataFrame with columns "city" and "countDistinct"
df.groupBy { city }.countDistinct()Return
A new DataFrame with group keys and corresponding numbers of distinct rows.
Parameters
The name of the result column that will store the number of distinct rows in each group. Defaults to "countDistinct".
Aggregates this GroupBy by counting the number of distinct combinations of values in the selected columns in each group.
Compares rows in each group based on the values in the selected columns. Returns a new DataFrame where each row corresponds to a group. The resulting DataFrame contains:
the original group key columns,
a new column (named resultName, default is
"countDistinct") that contains the number of distinct combinations of values in the selectedcolumnsin each group.
See also:
aggregate, which aggregates aGroupByusing the provided statistics.count, which counts the number of rows in each group.distinct, which removes duplicate rows and returns a newDataFrame.groupBy, which groups the rows of aDataFramebased on the values in one or more specified cols.
For more information: See countDistinct on the documentation website.
Select or express columns using the Columns Selection DSL.
This DSL is initiated by a Columns Selector lambda, which operates in the context of the Columns Selection DSL and expects you to return a SingleColumn or ColumnSet (so, a ColumnsResolver). This is an entity formed by calling any (combination) of the functions in the DSL that is or can be resolved into one or more columns.
The Columns Selection DSL allows using Extension Properties for specifying columns type- and name-safe.
Check out: Columns Selection DSL Grammar
See Column Selectors on the documentation website.
Example
// Counts unique combinations of values in the "year" and "title" columns
// for each city, returning a new DataFrame with columns "city" and "countDistinct"
df.groupBy { city }.countDistinct { year and title }Return
A new DataFrame with group keys and corresponding numbers of distinct combinations of values in the selected columns.
Parameters
The name of the result column that will store the number of distinct combinations of values in the selected columns in each group. Defaults to "countDistinct".
The ColumnsSelector used to select columns that will be considered for evaluating whether the rows are distinct.
Deprecated
It's recommended to migrate to the String or Extension Properties Access API https://kotlin.github.io/dataframe/apilevels.html