Split Spark Dataframe string column into multiple columns

PHOTO EMBED

Wed Feb 24 2021 17:36:03 GMT+0000 (Coordinated Universal Time)

Saved by @lorenzo_xcv #pyspark #spark #python #etl

split_col = pyspark.sql.functions.split(df['my_str_col'], '-')
df = df.withColumn('NAME1', split_col.getItem(0))
df = df.withColumn('NAME2', split_col.getItem(1))
content_copyCOPY

https://stackoverflow.com/questions/39235704/split-spark-dataframe-string-column-into-multiple-columns