I have added a new column to an existing datframe but it's not reflected in dataframe.
customerDf.withColumn("fullname",expr("concat(firstname,'|',lastname)"))
customerDf.show() # it's showing existing old df records without new columns.
we can see the results if we can assign the dataframe to another dataframe
test = customerDf.withColumn("fullname",expr("concat(firstname,'|',lastname)"))
test.show()
Is there any way to add a new column to an existing dataframe (without copy dataframe)?
We will have one option (inplace=True
in pandas). Do we have any similar function in pyspark?
question from:
https://stackoverflow.com/questions/65896658/what-is-the-method-to-add-new-column-in-existing-dataframe-in-pyspark 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…