QuestionQ37

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below must return a 25 percent sample of rows from DataFrame storesDF with reproducible results. Choose the response that correctly completes the numbered blanks in the code block to accomplish this.

StoresDF.__1__(__2__ = __3__, __4__ = __5__)  
Explanation

PySpark DataFrame.sample() uses fraction to specify the sampling proportion, so 0.25 requests a 25 percent sample. Providing an integer seed, such as 1234, initializes sampling deterministically so the result is reproducible. PySpark DataFrame.sample documentation

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!