Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 20, 2021 11:28
Embed
What would you like to do?
educationInvalid = '2n Cycle'
educationDefault = 'NONE'
# 다음 SQL 구문과 동일합니다.
#
# SELECT CASE WHEN education = '2n Cycle' THEN 'NONE' ELSE education as education
#
dfConverted2 = dfConverted1.withColumn(
"education",
when(col("education") == lit(educationInvalid), educationDefault).otherwise(col("education"))
)
dfConverted2.select("education").distinct().show()
# `show()` 의 출력 결과
+----------+
| education|
+----------+
| PhD|
| Master|
|Graduation|
| Basic|
| NONE|
+----------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment