0
我有一個pyspark數據框,模式如下所示。將元素添加到火花數據框中的現有結構中
root
|-- useragent: string (nullable = true)
|-- properties: struct (nullable = true)
| |-- browser: string (nullable = true)
| |-- device: string (nullable = true)
我正在使用udf + withColumn從useragent中提取更多信息。但我只能在新的專欄中存儲任何我正在創建的附加屬性。有沒有一種方法可以將它追加到結構本身?
我已經改變了模式,但它不轉讓所有我從其他屬性所需的數據已經存在
df = df.schema['properties'].dataType.add(StructField('type', StringType()))
難道更有意義,這轉換爲RDD?