Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Databricks Exam Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 Topic 1 Question 41 Discussion

Actual exam question for Databricks's Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 exam
Question #: 41
Topic #: 1
[All Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 Questions]

Which of the following code blocks immediately removes the previously cached DataFrame transactionsDf from memory and disk?

Show Suggested Answer Hide Answer
Suggested Answer: C

Correct code block:

transactionsDf.withColumn('cos', round(cos(degrees(transactionsDf.value)),2))

This Question: is especially confusing because col, 'cos' are so similar. Similar-looking answer options can also appear in the exam and, just like in this question, you need to pay attention to

the

details to identify what the correct answer option is.

The first answer option to throw out is the one that starts with withColumnRenamed: The Question: speaks specifically of adding a column. The withColumnRenamed operator only renames

an

existing column, however, so you cannot use it here.

Next, you will have to decide what should be in gap 2, the first argument of transactionsDf.withColumn(). Looking at the documentation (linked below), you can find out that the first argument of

withColumn actually needs to be a string with the name of the column to be added. So, any answer that includes col('cos') as the option for gap 2 can be disregarded.

This leaves you with two possible answers. The real difference between these two answers is where the cos and degree methods are, either in gaps 3 and 4, or vice-versa. From the QUESTION

NO: you

can find out that the new column should have 'the values in column value converted to degrees and having the cosine of those converted values taken'. This prescribes you a clear order of

operations: First, you convert values from column value to degrees and then you take the cosine of those values. So, the inner parenthesis (gap 4) should contain the degree method and then,

logically, gap 3 holds the cos method. This leaves you with just one possible correct answer.

More info: pyspark.sql.DataFrame.withColumn --- PySpark 3.1.2 documentation

Static notebook | Dynamic notebook: See test 3, Question: 49 (Databricks import instructions)


Contribute your Thoughts:

Aja
2 days ago
Hmm, 'del transactionsDf' might work, but I'm not sure if that actually removes it from disk. Better play it safe and go with the 'unpersist()' option.
upvoted 0 times
...
Burma
7 days ago
Alright, let's see here... B is the correct answer, 'unpersist()' is the way to go to remove that DataFrame from memory and disk.
upvoted 0 times
...
Jules
13 days ago
I'm not sure, but I think D) transactionsDf.clearCache() might also work.
upvoted 0 times
...
Nada
14 days ago
I agree with Brynn, unpersist() removes the DataFrame from memory and disk.
upvoted 0 times
...
Ruthann
15 days ago
Haha, what's the deal with option A? 'array_remove'? That's not even a thing in Spark, is it?
upvoted 0 times
...
Brynn
21 days ago
I think the answer is B) transactionsDf.unpersist().
upvoted 0 times
...

Save Cancel