У меня есть фрейм данных с несколькими данными, и я использую карту для преобразования и форматирования этой информации в другой фрейм данных с такой схемой:
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)
])))
])
Но поле значения (StructField ("value", StringType(), True)) в этой схеме иногда должен быть IntegerType, а иногда DoubleType для точного отражения типа при сохранении в Json.
Как мне помочь в этом случае?