我有一个包含多个信息的数据框,并且我使用map将这种信息转换并格式化为具有以下模式的另一个数据框:
FormatSchema =StructType([
StructField("description", ArrayType(StructType([
StructField("culture", StringType(), True),
StructField("value", StringType(), True)
]))),
StructField("key", StringType(), True),
StructField("version", StringType(), True),
StructField("timescope", StringType(), True),
StructField("viewdays", LongType(), True),
StructField("createdon", StringType(), True),
StructField("expireson", StringType(), True),
StructField("name", ArrayType(StructType([
StructField("culture", StringType(), True),
StructField("value", StringType(), True)
]))),
StructField("scopes", ArrayType(StructType([
StructField("key", StringType(), True),
StructField("value", StringType(), True),
StructField("scopes", ArrayType(StringType()),True)
]))),
StructField("messages", ArrayType(StructType([
StructField("condition", StringType(), True),
StructField("langset", StringType(), True),
StructField("properties", ArrayType(StructType([
StructField("key", StringType(), True),
StructField("value", StringType(), True),
]))),
StructField("resources", ArrayType(StructType([
StructField("culture", StringType(), True),
StructField("value", StringType(), True)
])))
]))),
StructField("values", ArrayType(StructType([
StructField("key", StringType(), True),
StructField("value", StringType(), True),
StructField("unit", StringType(), True),
StructField("type", StringType(), True),
StructField("uri", StringType(), True)
])))
])
但是当我保存在Json中时,该模式中的值字段(StructField(“ value”,StringType(),True))有时需要为IntegerType,有时需要为DoubleType以反映确切的类型。
在这种情况下如何为我提供帮助?