python - 如何获取数据框中列的架构(不是所有架构)?
问题描述
展平操作后我有一个数据框。
我想返回原始数据框。
例如: Df:
|-- delivery: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- load_delivery_intervals: array (nullable = true)
| | | |-- element: struct (containsNull = true)
| | | | |-- from_time: string (nullable = true)
| | | | |-- to_time: string (nullable = true)
| | |-- delivery_start_date_time: string (nullable = true)
| | |-- delivery_end_date_time: string (nullable = true)
| | |-- duration: string (nullable = true)
| | |-- week_days: array (nullable = true)
| | | |-- element: string (containsNull = true)
| | |-- delivery_capacity_quantity: string (nullable = true)
| | |-- quantity_unit: string (nullable = true)
我有一个数据框(展平),例如: flat_df_new:
delivery_from_time: string (nullable = true)
delivery_to_time: string (nullable = true)
delivery_delivery_start_date_time: string (nullable = true)
delivery_delivery_end_date_time: string (nullable = true)
delivery_duration: string (nullable = true)
delivery_delivery_capacity_quantity: string (nullable = true)
delivery_quantity_unit: string (nullable = true)
flat_df_new 是展平数据框(分解所有结构类型)并对其进行操作。
parentList 是在 df original 中分解的数组结构列表。
for parent in parentList:
df_temp=df.select(parent).schema <--get struct Type schema
flat_df_new=flat_df_new.withColumn(parent,....) <--- here now i want add a column named as parent variable but with schema as df_temp and value as column in flat_df_new.
感谢和问候
解决方案
推荐阅读
- angular - 角材料分页/打字稿
- ms-access - 字段值等于另一个表中的最大值
- android - Android文件意外结束
- python - 在 pandas 数据框中查找至少相隔 30 分钟但不是定期 30 分钟间隔的时间戳
- sql - 如何使用 oracle 数值函数对列中的值进行分类
- windows - 带有 EVR 输出的 DirectShow 旋转过滤器
- c# - 如何在实体框架中的多对多关系中按id查询?
- c# - 在 C# 中非常快速地处理串行端口字符串数据
- authorize.net - 授权 .NET 客户付款配置文件
- python - 如何解决 pydantic 模型不是 JSON 可序列化的