edf.select(\"x\").distinct.show() shows the distinct values that are present in x column of edf DataFrame.
edf.select(\"x\").distinct.show()
x
edf
Is there an efficient
import org.apache.spark.sql.functions.countDistinct df.groupBy("a").agg(countDistinct("s")).collect()