Shane works on a data analytics project and needs to perform analysis on employee data (Employee.csv file).

Schema: EmployeeID, EmployeeName, Age, Salary, Department.

Which of the below code snippet can be used to sort the employees based on the department in descending order?

logsRDD = sc.textFile("/dataset/Employee") 

FieldsRDD = logsRDD.map(lambda var1: var1.split(",")) 

logdata= FieldsRDD.map(lambda var1: (var1[4], [var1[0],var1[1],var1[2], var1[3]])) 

sortdata= logdata.sortByKey(ascending=False,keyfunc=lambda k: k)

logsRDD = sc.textFile("/dataset/Employee") 

FieldsRDD = logsRDD.map(lambda var1: var1.split(",")) 

logdata= FieldsRDD.map(lambda var1: (var1[4], [var1[0],var1[1],var1[2], var1[3]])) 

sortdata= logdata.sortByKey(ascending=True,keyfunc=lambda k: k)

logsRDD = sc.textFile("/dataset/Employee") 

FieldsRDD = logsRDD.map(lambda var1: var1.split(",")) 

logdata= FieldsRDD.map(lambda var1: (var1[4], [var1[0],var1[1],var1[2], var1[3]])) 

sortdata= logdata.sort(ascending=True,keyfunc=lambda k: k)

logsRDD = sc.textFile("/dataset/Employee") 

FieldsRDD = logsRDD.map(lambda var1: var1.split(",")) 

logdata= FieldsRDD.map(lambda var1: [(var1[0], var1[1],var1[2],var1[3], var1[4]])) 

sortdata= logdata.sort(ascending=False,keyfunc=lambda k: k)

Verified Answer
Correct Option - a

To get all Infosys Certified PySpark Professional Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in