Add to Chrome
✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
df.withColumn('status', when(col('age') < 18, 'minor').otherwise('adult'))
df.withColumn('status', if(col('age') < 18, 'minor', 'adult'))
df.selectExpr("CASE WHEN age < 18 THEN 'minor' ELSE 'adult' END as status")
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!