Databricks Certified Associate Developer for Apache Spark — Question 82
Which of the following operations can be used to return the number of rows in a DataFrame?
Answer options
- A. DataFrame.numberOfRows()
- B. DataFrame.n()
- C. DataFrame.sum()
- D. DataFrame.count()
- E. DataFrame.countDistinct()
Correct answer: D
Explanation
The correct method to return the number of rows in a DataFrame is DataFrame.count(), as it accurately counts all entries. The other options either do not exist or serve different purposes, such as summing values or counting distinct entries, which do not provide a row count.