【发布时间】:2021-12-26 04:48:49
【问题描述】:
我正在尝试将 int ID 和 3 个 int 数组转换为具有 2 列的数据帧,然后与 pyspark 中的另一个数据帧联合;
但是,我只是在与架构相关的错误之后遇到错误,并且似乎没有任何效果。我不确定这是为什么。
emp_rdd = spark.sparkContext.emptyRDD()
schema = StructType([
StructField("id", IntegerType(), True),
StructField("data", ArrayType(IntegerType()), True),])
df = spark.createDataFrame(data=emp_rdd, schema=schema)
columns = ['id','data']
for i in range(10):
data = [id, data1]
newRows = spark.createDataFrame(data,columns)
df= df.union(newRows)
这给了我这个错误;
无法推断类型的架构:
任何帮助将不胜感激
【问题讨论】:
标签: python dataframe apache-spark pyspark