split() function in pyspark

Published: 30 January 2026
on channel: Laksh
17
1

split() function in pyspark

#dataanlysis #dataengineering #pysparktutorial #python

from pyspark.sql.functions import *

data = [(1, "John smith"),
(2, "Alex luke")
]
df = spark.createDataFrame(data, ["id", "full_name"])

df.show()


df1=df.withColumn("Whole_Name",split("full_name"," "))
df1.show()


df2=df1.withColumn("First_Name",col("Whole_Name")[0])\
.withColumn("last_Name",col("Whole_Name")[1])

df2.show()


df3=df1.withColumn("First_lastName",explode("Whole_Name"))
df3.show()


On this page of the site you can watch the video online split() function in pyspark with a duration of hours minute second in good quality, which was uploaded by the user Laksh 30 January 2026, share the link with friends and acquaintances, this video has already been watched 17 times on youtube and it was liked by 1 viewers. Enjoy your viewing!