DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #146
Which of the following operations can be used to create a DataFrame with a subset of columns from DataFrame storesDF that are specified by name?
The correct answer is B. storesDF.select(). select() is the standard Spark DataFrame operation for projecting a subset of columns by name or column expression. For example, storesDF.select('col1', 'col2') returns a new DataFrame with only those columns. filter() operates on rows, not columns - it keeps all columns but…
Question
Which of the following operations can be used to create a DataFrame with a subset of columns from DataFrame storesDF that are specified by name?
Options
- AstoresDF.subset()
- BstoresDF.select()
- CstoresDF.selectColumn()
- DstoresDF.filter()
- EstoresDF.drop()
How the community answered
(20 responses)- B90% (18)
- D5% (1)
- E5% (1)
Explanation
select() is the standard Spark DataFrame operation for projecting a subset of columns by name or column expression. For example, storesDF.select('col1', 'col2') returns a new DataFrame with only those columns. filter() operates on rows, not columns - it keeps all columns but removes rows that don't match a condition. drop() works on columns but removes the named columns rather than selecting them. subset() and selectColumn() are not valid Spark DataFrame methods.
Topics
Community Discussion
No community discussion yet for this question.