I wrote code that transforms string into array of structs. I would like to do the same in python. Do you have any clue how can I do it?
import org.apache.spark.sql.DataFrame
import org.apache.spark.sql.functions._
import org.apache.spark.sql.Column
val df: DataFrame = Seq(
"adserviceCalculateCpcAlgorithmV1:2;searchProductsDecorator:3;searchOffersDecorator:3;bundlediscounts:5;searchGridType:3"
).toDF("abTests")
display(
df
.withColumn("abTestsArr", split($"abTests", ";"))
.withColumn("abTestsArr",
transform(col("abTestsArr"), (c: Column) => {
struct(
split(c, ":").getItem(0) as "name",
split(c, ":").getItem(1) as "group"
)
})
)
)