Question 12: KPMG Interview Questions part 1| data engineers | Unpivot
Вставка
- Опубліковано 4 лис 2024
- In this video I have discussed on Interview question asked in KPMG interview for data engineers.
Question 1:
You have a PySpark DataFrame named sales_data_df that represents monthly sales data for different products and stores.
After the transformation The new DataFrame should have three columns: 'Product', 'Month', and 'Sales'. Each row in the new DataFrame should represent the monthly sales data for a specific product.
sales_data = [
('Product_A', 100, 150, 200),
('Product_B', 120, 80, 110),
('Product_C', 90, 130, 180),
('Product_D', 200, 160, 120)
]
schema = StructType([
StructField('Product', StringType(), True),
StructField('Jan_Sales', IntegerType(), True),
StructField('Feb_Sales', IntegerType(), True),
StructField('Mar_Sales', IntegerType(), True)
])
sales_data_df = spark.createDataFrame(sales_data, schema)
Solution is in PySpark
Check out this video and do let me know your doubts we can connect on
linkedIn : / priyam-jain-0946ab199
Do subscribe @pysparkpulse for more such Questions.
#pyspark #spark #bigdata #bigdataengineer #dataengineering #dataengineer #deloitte #pwc #mnc
expecting many more interview questions from you till now i have enjoyed every session of yours.
Sure I am trying to gather questions and make video on that.
Glad you liked it
Nice Explanation! Thank you!
Thank you @swaraj