Enrollments Open for Certification Course on Artificial Intelligence and Deep Learning by IIT Roorkee

  Apply Now

Apache Spark - Transformations - map & filter

  • Map Transformation code in Scala

    val arr = 1 to 10000
    val nums = sc.parallelize(arr)
    def multiplyByTwo(x:Int):Int = x*2

    Write the following command in a new cell:


    Write the following command in a new cell:

    var dbls = nums.map(multiplyByTwo);
  • Transformations - filter() code in Scala

    var arr = 1 to 1000
    var nums = sc.parallelize(arr)
    def isEven(x:Int):Boolean = x%2 == 0

    Write the following commands in a new cell:

    var evens = nums.filter(isEven)

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...