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

前端 未结 6 1237
感动是毒
感动是毒 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条回答
  •  -上瘾入骨i
    2021-02-01 03:54

    Another option without resorting to sql functions

    df.groupBy('your_column_name').count().show()
    

    show will print the different values and their occurrences. The result without show will be a dataframe.

提交回复
热议问题