O'Reilly logo

Machine Learning with Spark - Second Edition by Nick Pentreath, Manpreet Singh Ghotra, Rajdeep Dua

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Movie dataset

Next, we will investigate a few properties of the movie catalog. We can inspect a row of the movie data file, as we did for the user data earlier, and then count the number of movies:

We will create a DataFrame of movie data by parsing using the format com.databrick.spark.csv and giving a | delimiter. Then, we use a CustomSchema to populate the DataFrame and return it:

def getMovieDataDF() : DataFrame = {   val customSchema = StructType(Array(   StructField("id", StringType, true),   StructField("name", StringType, true),   StructField("date", StringType, true),   StructField("url", StringType, true)));   val movieDf = spark.read.format(    "com.databricks.spark.csv")      .option("delimiter", "|").schema(customSchema)  .load(PATH_MOVIES) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required