I am trying to multiply an array typed column by a scalar. This scalar is also a value from the same PySpark dataframe.
For example, I have this dataframe:
df = sc.parallelize([([1, 2],3)]).toDF(["l","factor"])
+------+------+
| l|factor|
+------+------+
|[1, 2]| 3|
+------+------+
What I want to achieve is this:
+------+------+
| l|factor|
+------+------+
|[3, 6]| 3|
+------+------+
This is what I have tried:
df.withColumn("l", lit("factor") * df.l)
It returns a type mismatch error. How can I multiply an array typed column by a number?