Databricks Certified Associate Developer for Apache Spark Exam Practice Questions (P. 5)
- Full Access (207 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #21
Which of the following code blocks returns a DataFrame containing only the rows from DataFrame storesDF where the value in column sqft is less than or equal to 25,000 OR the value in column customerSatisfaction is greater than or equal to 30?
- AstoresDF.filter(col("sqft") <= 25000 | col("customerSatisfaction") >= 30)
- BstoresDF.filter(col("sqft") <= 25000 or col("customerSatisfaction") >= 30)
- CstoresDF.filter(sqft <= 25000 or customerSatisfaction >= 30)
- DstoresDF.filter(col(sqft) <= 25000 | col(customerSatisfaction) >= 30)
- EstoresDF.filter((col("sqft") <= 25000) | (col("customerSatisfaction") >= 30))Most Voted
Correct Answer:
E
E
send
light_mode
delete
Question #22
Which of the following code blocks returns a new DataFrame from DataFrame storesDF where column storeId is of the type string?
- AstoresDF.withColumn("storeId, cast(col("storeId"), StringType()))
- BstoresDF.withColumn("storeId, col("storeId").cast(StringType()))Most Voted
- CstoresDF.withColumn("storeId, cast(storeId).as(StringType)
- DstoresDF.withColumn("storeId, col(storeId).cast(StringType)
- EstoresDF.withColumn("storeId, cast("storeId").as(StringType()))
Correct Answer:
B
B
send
light_mode
delete
Question #23
Which of the following code blocks returns a new DataFrame with a new column employeesPerSqft that is the quotient of column numberOfEmployees and column sqft, both of which are from DataFrame storesDF? Note that column employeesPerSqft is not in the original DataFrame storesDF.
- AstoresDF.withColumn("employeesPerSqft", col("numberOfEmployees") / col("sqft"))Most Voted
- BstoresDF.withColumn("employeesPerSqft", "numberOfEmployees" / "sqft")
- CstoresDF.select("employeesPerSqft", "numberOfEmployees" / "sqft")
- DstoresDF.select("employeesPerSqft", col("numberOfEmployees") / col("sqft"))
- EstoresDF.withColumn(col("employeesPerSqft"), col("numberOfEmployees") / col("sqft"))
Correct Answer:
A
A
send
light_mode
delete
Question #24
The code block shown below should return a new DataFrame from DataFrame storesDF where column modality is the constant string "PHYSICAL", Assume DataFrame storesDF is the only defined language variable. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.
Code block:
storesDF. _1_(_2_,_3_(_4_))
Code block:
storesDF. _1_(_2_,_3_(_4_))
- A1. withColumn
2. "modality"
3. col
4. "PHYSICAL" - B1. withColumn
2. "modality"
3. lit
4. PHYSICAL - C1. withColumn
2. "modality"
3. lit
4. "PHYSICAL"Most Voted - D1. withColumn
2. "modality"
3. SrtringType
4. "PHYSICAL" - E1. newColumn
2. modality
3. SrtringType
4. PHYSICAL
Correct Answer:
C
C
send
light_mode
delete
Question #25
Which of the following code blocks returns a DataFrame where column storeCategory from DataFrame storesDF is split at the underscore character into column storeValueCategory and column storeSizeCategory?
A sample of DataFrame storesDF is displayed below:
A sample of DataFrame storesDF is displayed below:

- A(storesDF.withColumn("storeValueCategory", split(col("storeCategory"), "_")[1])
.withColumn("storeSizeCategory", split(col("storeCategory"), "_")[2])) - B(storesDF.withColumn("storeValueCategory", col("storeCategory").split("_")[0])
.withColumn("storeSizeCategory", col("storeCategory").split("_")[1])) - C(storesDF.withColumn("storeValueCategory", split(col("storeCategory"), "_")[0])
.withColumn("storeSizeCategory", split(col("storeCategory"), "_")[1]))Most Voted - D(storesDF.withColumn("storeValueCategory", split("storeCategory", "_")[0])
.withColumn("storeSizeCategory", split("storeCategory", "_")[1])) - E(storesDF.withColumn("storeValueCategory", col("storeCategory").split("_")[1])
.withColumn("storeSizeCategory", col("storeCategory").split("_")[2]))
Correct Answer:
C
C
send
light_mode
delete
All Pages