DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #46
Which of the following operations can be used to return a new DataFrame from DataFrame storesDF without columns that are specified by name?
The correct answer is C. storesDF.drop(). drop() removes one or more columns from a DataFrame by name and returns a new DataFrame with those columns excluded. For example, storesDF.drop('columnName') removes that column. filter() operates on rows, not columns. select() is used to choose which columns to keep (not…
Question
Which of the following operations can be used to return a new DataFrame from DataFrame storesDF without columns that are specified by name?
Options
- AstoresDF.filter()
- BstoresDF.select()
- CstoresDF.drop()
- DstoresDF.subset()
- EstoresDF.dropColumn()
How the community answered
(25 responses)- A4% (1)
- C92% (23)
- D4% (1)
Explanation
drop() removes one or more columns from a DataFrame by name and returns a new DataFrame with those columns excluded. For example, storesDF.drop('columnName') removes that column. filter() operates on rows, not columns. select() is used to choose which columns to keep (not remove), though you could technically exclude columns by selecting all others. subset() and dropColumn() are not valid Spark DataFrame methods.
Topics
Community Discussion
No community discussion yet for this question.