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?