输入数据
import pandas as pd
import numpy as np
a1=["data.country", "data.studentinfo.city","data.studentinfo.name.id.grant"]
a2=["StringType()","StringType()","StringType()"]
d1=pd.DataFrame(list(zip(a1,a2)),columns=['action','type'])
我们必须使用 Dataframe 和for循环构建以下结构
StructType([StructField("data",
StructType([StructField("country",StringType(),True),
StructField("studentinfo",
StructType([StructField("city",StringType(),True),
StructField("name",StructType([
StructField("id",StructType([
StructField("grant",StringType(),True)])
)]))
])
)])
)])
1条答案
按热度按时间46qrfjad1#
第一阶段是构建结构,然后函数将其转换为以下格式: