【问题标题】:How to remove specific element from a column which is struct type array如何从结构类型数组的列中删除特定元素
【发布时间】:2021-11-15 18:28:35
【问题描述】:

有一个表有 10 列。 列类型之一是 struct 并假设列名是 xyz。 xyz 包含元素数组。

例如, xyz 列包含 [a:值 1,b:值 2,c:值 3...] 现在我想从这个数组中删除 c 元素。

我该怎么做?

这段代码需要在pyspark/python中完成。

【问题讨论】:

标签: python arrays json pyspark struct


【解决方案1】:

您必须使用df.select('xyz.*') 之类的东西来展平您的结构,然后根据需要使用array functionstruct function 对其进行重组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-27
    • 2019-06-03
    相关资源
    最近更新 更多