How to replace data from specific column only in spark scala
Input:
Output:
Solution:
#excaclty we read file first
val df = spark.read.format("csv").option("header","True").load("file:///D:/idname.txt")
df.show()
#here, we choose fname column for change string data 'Shah' to null
val result_df = df.withColumn("fname",when(col("fname")==="Shah",null).otherwise(col("fname")))
result_df.show()
Comments
Post a Comment