DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #14
Which of the following operations can be used to return the number of rows in a DataFrame?
The correct answer is D. DataFrame.count(). DataFrame.count() is the standard PySpark action that triggers a full scan of the DataFrame and returns the total number of rows as a Python integer. The other options do not exist or serve different purposes: numberOfRows() (A) and n() (B) are not PySpark DataFrame methods…
Question
Which of the following operations can be used to return the number of rows in a DataFrame?
Options
- ADataFrame.numberOfRows()
- BDataFrame.n()
- CDataFrame.sum()
- DDataFrame.count()
- EDataFrame.countDistinct()
How the community answered
(61 responses)- B2% (1)
- C7% (4)
- D89% (54)
- E3% (2)
Explanation
DataFrame.count() is the standard PySpark action that triggers a full scan of the DataFrame and returns the total number of rows as a Python integer. The other options do not exist or serve different purposes: numberOfRows() (A) and n() (B) are not PySpark DataFrame methods; sum() (C) aggregates numeric column values, not row counts; and countDistinct() (E) is a SQL function used inside aggregations to count distinct values in a column, not a top-level DataFrame method that counts rows.
Topics
Community Discussion
No community discussion yet for this question.