I have a field within an array as below.
|-- col1: string (nullable = true)
|-- col2: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- cola: string (nullable = true)
| | |-- colb: string (nullable = true)
I have done some calculation on colb using myudf which is within the array col2.
myDF=myDF.withColumn(colb, myudf(colb))
When I use withColumn, it creates a new column but I want to replace the existing column with new value. Can anyone suggest how this can be done.
|-- col1: string (nullable = true)
|-- col2: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- cola: string (nullable = true)
| | |-- colb: string (nullable = true)
|-- colb: array (nullable = true)