PySpark Practice Question | Map Adult and Child based on Age

 from pyspark.sql.types import *

data =[('A1','Adult',55),
('A2','Adult',56),
('A3','Adult',57),
('A4','Adult',58),
('A5','Adult',59),
('C1','Child',11),
('C2','Child',12),
('C3','Child',13),
('C4','Child',14)]
schema =["Name","Category","Age"]
df1=spark.createDataFrame(data,schema)
display(df1)

Comments

Popular posts from this blog

PySpark Interview Question | Retrieve orders who sold multiple products

PySpark Practice Question | Return companies with high profits