I was implementing the answer mentioned here. This is my struct and I want to add a new col to it.
root
|-- shops: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- epoch: double (nullable = true)
| | |-- request: string (nullable = true)
So I executed this
from pyspark.sql import functions as F
df = new_df.withColumn('state', F.col('shops').withField('a', F.lit(1)))
df.printSchema()
But I get this error
TypeError Traceback (most recent call last)
<ipython-input-47-1749b2131995> in <module>
1 from pyspark.sql import functions as F
----> 2 df = new_df.withColumn('state', F.col(‘shops’).withField('a', F.lit(1)))
3 df.printSchema()
TypeError: 'Column' object is not callable
EDIT: My version is Python 39 Spark 3.0.3 (Max possible)