我想用下面的代码在PySpark中创建一个数据帧
from pyspark.sql import *
from pyspark.sql.types import *
temp = Row("DESC", "ID")
temp1 = temp('Description1323', 123)
print temp1
schema = StructType([StructField("DESC", StringType(), False),
StructField("ID", IntegerType(), False)])
df = spark.createDataFrame(temp1, schema)
但我收到以下错误:
TypeError: StructType can not accept object 'Description1323' in type type 'str'
我的代码怎么了?在
问题是您正在传递一个
Row
,而您应该传递一个Row
s的列表。请尝试以下操作:结果是:
^{pr2}$相关问题 更多 >
编程相关推荐