Valid Associate-Developer-Apache-Spark Dumps shared by EduDump.com for Helping Passing Associate-Developer-Apache-Spark Exam! EduDump.com now offer the newest Associate-Developer-Apache-Spark exam dumps, the EduDump.com Associate-Developer-Apache-Spark exam questions have been updated and answers have been corrected get the newest EduDump.com Associate-Developer-Apache-Spark dumps with Test Engine here:
The code block shown below should return a single-column DataFrame with a column named consonant_ct that, for each row, shows the number of consonants in column itemName of DataFrame itemsDf. Choose the answer that correctly fills the blanks in the code block to accomplish this. DataFrame itemsDf: 1.+------+----------------------------------+-----------------------------+-------------------+ 2.|itemId|itemName |attributes |supplier | 3.+------+----------------------------------+-----------------------------+-------------------+ 4.|1 |Thick Coat for Walking in the Snow|[blue, winter, cozy] |Sports Company Inc.| 5.|2 |Elegant Outdoors Summer Dress |[red, summer, fresh, cooling]|YetiX | 6.|3 |Outdoors Backpack |[green, summer, travel] |Sports Company Inc.| 7.+------+----------------------------------+-----------------------------+-------------------+ Code block: itemsDf.select(__1__(__2__(__3__(__4__), "a|e|i|o|u|\s", "")).__5__("consonant_ct"))
Correct Answer: D
Explanation Correct code block: itemsDf.select(length(regexp_replace(lower(col("itemName")), "a|e|i|o|u|\s", "")).alias("consonant_ct")) Returned DataFrame: +------------+ |consonant_ct| +------------+ | 19| | 16| | 10| +------------+ This question tries to make you think about the string functions Spark provides and in which order they should be applied. Arguably the most difficult part, the regular expression "a|e|i|o|u| \s", is not a numbered blank. However, if you are not familiar with the string functions, it may be a good idea to review those before the exam. The size operator and the length operator can easily be confused. size works on arrays, while length works on strings. Luckily, this is something you can read up about in the documentation. The code block works by first converting all uppercase letters in column itemName into lowercase (the lower() part). Then, it replaces all vowels by "nothing" - an empty character "" (the regexp_replace() part). Now, only lowercase characters without spaces are included in the DataFrame. Then, per row, the length operator counts these remaining characters. Note that column itemName in itemsDf does not include any numbers or other characters, so we do not need to make any provisions for these. Finally, by using the alias() operator, we rename the resulting column to consonant_ct. More info: - lower: pyspark.sql.functions.lower - PySpark 3.1.2 documentation - regexp_replace: pyspark.sql.functions.regexp_replace - PySpark 3.1.2 documentation - length: pyspark.sql.functions.length - PySpark 3.1.2 documentation - alias: pyspark.sql.Column.alias - PySpark 3.1.2 documentation Static notebook | Dynamic notebook: See test 2