Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created Dec 20, 2021
Embed
What would you like to do?
dfConverted1 = dfSelected\
withColumn("count_children", coalesce("count_kid", lit(0)) + coalesce("count_teen", lit(0)))
dfConverted1\
.select(col("id"), col("count_kid"), col("count_teen"), col("count_children"))\
.limit(5)\
.show()
# `show() 출력 결과
+----+---------+----------+--------------+
| id|count_kid|count_teen|count_children|
+----+---------+----------+--------------+
|5524| 0| 0| 0|
|2174| 1| 1| 2|
|4141| 0| 0| 0|
|6182| 1| 0| 1|
|5324| 1| 0| 1|
+----+---------+----------+--------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment