pyspark.sql.functions.count_distinct¶
-
pyspark.sql.functions.
count_distinct
(col: ColumnOrName, *cols: ColumnOrName) → pyspark.sql.column.Column¶ Returns a new
Column
for distinct count ofcol
orcols
.Examples
>>> df.agg(count_distinct(df.age, df.name).alias('c')).collect() [Row(c=2)]
>>> df.agg(count_distinct("age", "name").alias('c')).collect() [Row(c=2)]