QuestionQ106

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks produces a DataFrame in which the divisionDistinct column contains the approximate count of distinct values in the division column from DataFrame storesDF?

Explanation

approx_count_distinct(col("division")) creates an aggregate expression that estimates the number of unique values in division. DataFrame.agg() evaluates that aggregate over the DataFrame, and alias("divisionDistinct") assigns the required result-column name. Apache Spark: approx_count_distinct

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!