Databricks Certified Associate Developer For Apache Spark 30 · Free Practice Question Easy

Question 3

The code block shown below should return a DataFrame with column only aSquared dropped from DataFrame df. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. 


Code block: 

df.__1__(__2__)

  • A

    1. remove

    2. “aSquared”

  • B

    1. drop

    2. “aSquared”

Reveal correct answer

Correct answer: B

Explanation


The drop() method of the DataFrame class in Apache Spark is used to drop a column from a DataFrame. It takes a single argument which is the name of the column to be dropped.

Here is an example of how to use drop() in Scala:

This will produce a new DataFrame newDf with the same rows as the original DataFrame df, but with the column age removed:

In Python, you can use the following code to achieve the same result:


Correct usage of drop function is the following:

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need