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…
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)- A2% (1)
- B2% (1)
- C7% (4)
- D87% (47)
- E2% (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
Community Discussion
No community discussion yet for this question.