【发布时间】:2019-04-09 06:41:01
【问题描述】:
本质上这是比较两个数据帧,我可以将它们的名称与:
def diff(first, second):
second = set(second)
return [item for item in first if item not in second]
但我还想不仅在名称上进行比较,还想在数据类型上进行比较
示例数据框如下:
>>> pDF1.schema
StructType(
List(
StructField(Scen_Id,IntegerType,true),
StructField(Flow_Direction,StringType,true),
StructField(Dataset_Type,StringType,true),
StructField(Flag_Extrapolation_Percent_Change_Stay,IntegerType,true)
)
)
>>> pDF2.schema
StructType(
List(
StructField(Scen_Id,StringType,true),
StructField(Flow_Direction,StringType,true),
StructField(Dataset_Type,StringType,true),
StructField(Flag_Extrapolation_Percent_Change_Stay,IntegerType,true)
)
)
您可以从这个特殊的简化示例中看到(通常我们的数据帧包含超过 100 个字段),pDF2 与 pDF1 具有相同的名称/数据类型,但第一个字段具有不同的数据类型。
非常感谢。
【问题讨论】: