Which of the following code blocks returns a DataFrame that has all columns of DataFrame transactionsDf and an additional column predErrorSquared which is the squared value of column predError in DataFrame transactionsDf?
Answer(s): C
While only one of these code blocks works, the DataFrame API is pretty flexible when it comes to accepting columns into the pow() method. The following code blocks would also work: transactionsDf.withColumn("predErrorSquared", pow("predError", 2)) transactionsDf.withColumn("predErrorSquared", pow("predError", lit(2)))Static notebook | Dynamic notebook: See test 1, Question: 26 (Databricks import instructions) (https://flrs.github.io/spark_practice_tests_code/#1/26.html ,https://bit.ly/sparkpracticeexams_import_instructions)
The code block displayed below contains an error. The code block should return a new DataFramethat only contains rows from DataFrame transactionsDf in which the value in column predError is at least 5. Find the error. Code block:transactionsDf.where("col(predError) >= 5")
Answer(s): A
The argument to the where method cannot be a string. It can be a string, no problem here.Instead of where(), filter() should be used.No, that does not matter. In PySpark, where() and filter() are equivalent. Instead of >=, the SQL operator GEQ should be used.Incorrect.The expression returns the original DataFrame transactionsDf and not a new DataFrame. To avoid this, the code block should be transactionsDf.toNewDataFrame().where("col(predError) >= 5").No, Spark returns a new DataFrame.Static notebook | Dynamic notebook: See test 1, Question: 27 (Databricks import instructions) (https://flrs.github.io/spark_practice_tests_code/#1/27.html ,https://bit.ly/sparkpracticeexams_import_instructions)
Which of the following code blocks saves DataFrame transactionsDf in location/FileStore/transactions.csv as a CSV file and throws an error if a file already exists in the location?
Answer(s): E
Static notebook | Dynamic notebook: See test 1, question 28 (Databricks import instructions) (https://flrs.github.io/spark_practice_tests_code/#1/28.html ,https://bit.ly/sparkpracticeexams_import_instructions)
The code block shown below should return a DataFrame with two columns, itemId and col. In this DataFrame, for each element in column attributes of DataFrame itemDf there should be a separate row in which the column itemId contains the associated itemId from DataFrame itemsDf. The new DataFrame should only contain rows for rows in DataFrame itemsDf in which the column attributes contains the element cozy.A sample of DataFrame itemsDf is below.Code block:itemsDf. 1 ( 2 ). 3 ( 4 , 5 ( 6 ))
The correct code block is:itemsDf.filter("array_contains(attributes, 'cozy')").select("itemId", explode("attributes"))The key here is understanding how to use array_contains(). You can either use it as an expression in a string, or you can import it from pyspark.sql.functions. In that case, the following would also work:itemsDf.filter(array_contains("attributes", "cozy")).select("itemId", explode("attributes")) Static notebook | Dynamic notebook: See test 1, Question: 29 (Databricks import instructions) (https://flrs.github.io/spark_practice_tests_code/#1/29.html ,https://bit.ly/sparkpracticeexams_import_instructions)
The code block displayed below contains an error. The code block should return the average of rows in column value grouped by unique storeId. Find the error.Code block: transactionsDf.agg("storeId").avg("value")
Answer(s): D
Static notebook | Dynamic notebook: See test 1, Question: 30 (Databricks import instructions) (https://flrs.github.io/spark_practice_tests_code/#1/30.html ,https://bit.ly/sparkpracticeexams_import_instructions)
Post your Comments and Discuss Databricks DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3.0 exam dumps with other Community members:
Ravi Commented on March 03, 2025 Good documentation Anonymous
amrith Commented on December 09, 2024 more questions on databricks as well please Anonymous
jeff Commented on December 09, 2024 This took the pressure out of preparation as I read everywhere that this exam is really hard. Wonderful resource. UNITED STATES
CoolMo Commented on December 09, 2024 A friend gave me the address to this site he said he passed his Azure exam using their practice questions. I hope it can help me with my exam as well. EUROPEAN UNION
Tyler Commented on December 09, 2024 This is BIG help. I don't want to discount the fact that these questions are very similar to those in real exam. Way to go guys. Canada
amrith Commented on December 09, 2024 Documentation Anonymous
bharathi Commented on January 21, 2024 good explanation UNITED STATES
Bano Commented on January 19, 2024 What % of questions do we get in the real exam? UNITED STATES
Bano Commented on January 19, 2024 what % of questions do we get in the real exam? UNITED STATES
Our website is free, but we have to fight against AI bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3.0 content, but please register or login to continue.