【发布时间】:2019-12-22 15:05:18
【问题描述】:
enter image description here我怎样才能创建一个空结构的数据框。? 谢谢。
dataxx = []
schema = StructType(
[
StructField('Info1',
StructType([
StructField('fld', IntegerType(),True),
StructField('fld1', IntegerType(),True),
StructField('fld2', IntegerType(),True),
StructField('fld3', IntegerType(),True),
StructField('fld4', IntegerType(),True),
])
),
]
)
df = sqlCtx.createDataFrame(dataxx, schema)
感谢您的帮助
【问题讨论】:
-
与熊猫无关..已删除
-
你试过
spark.createDataFrame([], schema)吗? -
@blackbishop 谢谢,但这不是我的意思。我想创建这样的数据框结构体。我添加了一张图片以便更好地理解。
标签: python-3.x apache-spark-sql pyspark-sql pyspark-dataframes