How to count occurrences of each distinct value for every column in a dataframe?

前端 未结 6 1238
感动是毒
感动是毒 2021-02-01 03:48

edf.select(\"x\").distinct.show() shows the distinct values that are present in x column of edf DataFrame.

Is there an efficient

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 04:06

    import org.apache.spark.sql.functions.countDistinct
    
    df.groupBy("a").agg(countDistinct("s")).collect()
    

提交回复
热议问题