【发布时间】:2020-04-01 21:52:07
【问题描述】:
我是 pyspark 的新手。我试图了解如何使用多层嵌套结构和数组访问镶木地板文件。我需要用 null 替换数据帧(带有嵌套模式)中的一些值,我已经看到这个 solution 它适用于结构,但不确定它如何适用于数组。
我的架构是这样的
|-- unitOfMeasure: struct
| |-- raw: struct
| | |-- id: string
| | |-- codingSystemId: string
| | |-- display: string
| |-- standard: struct
| | |-- id: string
| | |-- codingSystemId: string
|-- Id: string
|-- actions: array
| |-- element: struct
| | |-- action: string
| | |-- actionDate: string
| | |-- actor: struct
| | | |-- actorId: string
| | | |-- aliases: array
| | | | |-- element: struct
| | | | | |-- value: string
| | | | | |-- type: string
| | | | | |-- assigningAuthority: string
| | | |-- fullName: string
我想要做的是将 unitOfMeasure.raw.id 替换为 null
和actions.element.action 为空
和 actions.element.actor.aliases.element.value 与 null 保持我的数据框的其余部分保持不变。
有什么方法可以实现吗?
【问题讨论】:
标签: apache-spark pyspark apache-spark-sql pyspark-sql