nerdexam
Databricks

DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #15

Which of the following operations returns a GroupedData object?

The correct answer is D. DataFrame.groupBy(). DataFrame.groupBy() (also spelled groupby()) is the correct PySpark method that groups the DataFrame by one or more columns and returns a GroupedData object, on which aggregation functions like .agg(), .count(), .sum(), etc., can be called. The other options are invalid…

Spark DataFrame Transformations

Question

Which of the following operations returns a GroupedData object?

Options

  • ADataFrame.GroupBy()
  • BDataFrame.cubed()
  • CDataFrame.group()
  • DDataFrame.groupBy()
  • EDataFrame.grouping_id()

How the community answered

(54 responses)
  • A
    2% (1)
  • B
    2% (1)
  • C
    7% (4)
  • D
    87% (47)
  • E
    2% (1)

Explanation

DataFrame.groupBy() (also spelled groupby()) is the correct PySpark method that groups the DataFrame by one or more columns and returns a GroupedData object, on which aggregation functions like .agg(), .count(), .sum(), etc., can be called. The other options are invalid: GroupBy() (A) uses incorrect capitalization; cubed() (B) does not exist; group() (C) does not exist; and grouping_id() (E) is a window/grouping function used inside aggregation expressions, not a DataFrame method that returns a GroupedData object.

Topics

#Spark DataFrame#Grouping Operations#groupBy() method#Data Aggregation

Community Discussion

No community discussion yet for this question.

Full DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Practice