nerdexam
Databricks

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…

Working with Spark DataFrames and Transformations

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)
  • A
    4% (1)
  • C
    92% (23)
  • D
    4% (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

#DataFrame Operations#Column Manipulation#Spark API#Data Transformation

Community Discussion

No community discussion yet for this question.

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