JLL Pyspark Interview Question - Get Top3 pickup locations

One of the Pyspark Interview question recently asked in JLL interview. We need to Get Top3 pickup locations. Lets see how we can achieve this by using GroupBy count and limit. Mentioning the dataframe details here from pyspark.sql.types import StructType, StructField, StringType, IntegerType Define the schema schema = StructType([ StructField("reqid", IntegerType(), True), StructField("pickup_location", StringType(), True) ]) Create a DataFrame with the defined schema data = [(48, "Airport"), (49, "Office"),(50, "Hospital"),(51, "Airport"),(52, "Hospital"),(53, "Shoppingmall"),(54, "Office"),(55, "Hospital"),(56, "Hospital")] pickup_df = spark.createDataFrame(data, schema) pickup_df.display() For more Azure Data Bricks interview questions. Check out our playlist.    • DataBricks and PySpark Interview Questions   Contact us: [email protected] Follow us on Instagram : instagram.com/cloudchallengers Facebook : facebook.com/cloudchallengers LinkedIn : linkedin.com/company/cloudchallengers