Associate-Developer-Apache-Spark Exam Question 26

Which of the following code blocks returns only rows from DataFrame transactionsDf in which values in column productId are unique?
  • Associate-Developer-Apache-Spark Exam Question 27

    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")))
  • Associate-Developer-Apache-Spark Exam Question 28

    Which of the following code blocks reads all CSV files in directory filePath into a single DataFrame, with column names defined in the CSV file headers?
    Content of directory filePath:
    1._SUCCESS
    2._committed_2754546451699747124
    3._started_2754546451699747124
    4.part-00000-tid-2754546451699747124-10eb85bf-8d91-4dd0-b60b-2f3c02eeecaa-298-1-c000.csv.gz
    5.part-00001-tid-2754546451699747124-10eb85bf-8d91-4dd0-b60b-2f3c02eeecaa-299-1-c000.csv.gz
    6.part-00002-tid-2754546451699747124-10eb85bf-8d91-4dd0-b60b-2f3c02eeecaa-300-1-c000.csv.gz
    7.part-00003-tid-2754546451699747124-10eb85bf-8d91-4dd0-b60b-2f3c02eeecaa-301-1-c000.csv.gz spark.option("header",True).csv(filePath)
  • Associate-Developer-Apache-Spark Exam Question 29

    Which of the following code blocks returns a copy of DataFrame transactionsDf where the column storeId has been converted to string type?
  • Associate-Developer-Apache-Spark Exam Question 30

    Which of the following code blocks applies the boolean-returning Python function evaluateTestSuccess to column storeId of DataFrame transactionsDf as a user-defined function?