nerdexam
Databricks

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…

Performing Basic DataFrame Transformations

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)
  • B
    90% (18)
  • D
    5% (1)
  • E
    5% (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

#Spark DataFrame#Column Selection#DataFrame Transformations#PySpark

Community Discussion

No community discussion yet for this question.

Full DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Practice