The code block displayed below contains an error. The code block should produce a DataFrame with color as the only column and three rows with color values of red, blue, and green, respectively.
Find the error.
Code block:
1.spark.createDataFrame([("red",), ("blue",), ("green",)], "color")
2.Instead of calling spark.createDataFrame, just DataFrame should be called.
A. The commas in the tuples with the colors should be eliminated.The code block displayed below contains an error. The code block should return a DataFrame in which column predErrorAdded contains the results of Python function add_2_if_geq_3 as applied to numeric and nullable column predError in DataFrame transactionsDf.
Find the error.
Code block:
1.def add_2_if_geq_3(x):
2.
if x is None:
3.
return x
4.
elif x >= 3:
5.
return x+2
6.
return x
7.
8.add_2_if_geq_3_udf = udf(add_2_if_geq_3)
9.
10.transactionsDf.withColumnRenamed("predErrorAdded", add_2_if_geq_3_udf(col("predError")))
A. The operator used to adding the column does not add column predErrorAdded to the DataFrame.The code block shown below should add column transactionDateForm to DataFrame transactionsDf. The column should express the unix-format timestamps in column transactionDate as string type like Apr 26 (Sunday). Choose the answer that correctly fills the blanks in the code block to accomplish this.
transactionsDf.__1__(__2__, from_unixtime(__3__, __4__))
A. 1. withColumn 2. "transactionDateForm" 3. "MMM d (EEEE)" 4. "transactionDate"Which of the following code blocks returns a single-column DataFrame of all entries in Python list throughputRates which contains only float-type values ?
A. spark.createDataFrame((throughputRates), FloatType)Which of the following code blocks returns a DataFrame with approximately 1,000 rows from the 10,000-row DataFrame itemsDf, without any duplicates, returning the same rows even if the code block is run twice?
A. itemsDf.sampleBy("row", fractions={0: 0.1}, seed=82371)Which of the following code blocks performs an inner join between DataFrame itemsDf and DataFrame transactionsDf, using columns itemId and transactionId as join keys, respectively?
A. itemsDf.join(transactionsDf, "inner", itemsDf.itemId == transactionsDf.transactionId)Which of the following code blocks returns the number of unique values in column storeId of DataFrame transactionsDf?
A. transactionsDf.select("storeId").dropDuplicates().count()The code block shown below should return a one-column DataFrame where the column storeId is converted to string type. Choose the answer that correctly fills the blanks in the code block to accomplish this.
transactionsDf.__1__(__2__.__3__(__4__))
A. 1. select 2. col("storeId") 3. cast 4. StringTypeThe code block shown below should return a two-column DataFrame with columns transactionId and supplier, with combined information from DataFrames itemsDf and transactionsDf. The code block should merge rows in which column productId of DataFrame transactionsDf matches the value of column itemId in DataFrame itemsDf, but only where column storeId of DataFrame
transactionsDf does not match column itemId of DataFrame itemsDf. Choose the answer that correctly fills the blanks in the code block to accomplish this.
Code block:
transactionsDf.__1__(itemsDf, __2__).__3__(__4__)
A. 1. join 2. transactionsDf.productId==itemsDf.itemId, how="inner" 3. select 4. "transactionId", "supplier"Which of the following code blocks reads in parquet file /FileStore/imports.parquet as a DataFrame?
A. spark.mode("parquet").read("/FileStore/imports.parquet")Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only Databricks exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK exam preparations and Databricks certification application, do not hesitate to visit our Vcedump.com to find your solutions here.