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

Question 16

The code block shown below should return a new DataFrame with 25 percent of random records from dataframe df without replacement. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. 


Code block:

df._1_(_2_, _3_, _4_)

  • A

    1. sample

    2. false

    3 .25

    4. 5

  • B

    1. random

    2. false

    3. 0.25

    4. 5

  • C

    1. sample

    2. false

    3. 0.25

    4. 5

  • D

    1. sample

    2. false

    3. 0.5

    4. 25

  • E

    1. take

    2. false

    3. 0.25

    4. 5

  • F

    1. sample

    2. true

    3. 0.25

    4. 5

Reveal correct answer

Correct answer: C

Explanation

one example of sample will look like this


df.sample(false, 0.25, 5)


Seed parameter, third parameter for this function is used to save the state of a random function, so that it can generate same random numbers on multiple executions of the code on the same machine or on different machines (for a specific seed value).


so the last parameter seed is not really important for this question.

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