April 2017
Intermediate to advanced
532 pages
12h 39m
English
Let's take a looks at the year of movie review and clean it up.
We have already seen an example of filtering out bad data. Following on from the preceding code, the following code snippet applies the fill-in approach to the bad release date record by assigning a value which is Empty String as 1900 (this will be later replaced by the Median):
Util.spark.udf.register("convertYear", Util.convertYear _) movie_data_df.show(false) val movie_years = Util.spark.sql("select convertYear(date) as year from movie_data") movie_years.createOrReplaceTempView("movie_years") Util.spark.udf.register("replaceEmptyStr", replaceEmptyStr _) val years_replaced = Util.spark.sql("select replaceEmptyStr(year) as r_year from movie_years") ...Read now
Unlock full access