Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 20, 2021 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1ambda/f3704bee6946627a5e42afff7639d3f7 to your computer and use it in GitHub Desktop.
Save 1ambda/f3704bee6946627a5e42afff7639d3f7 to your computer and use it in GitHub Desktop.
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