2
當我試圖通過RDD轉換的火花,數據幀和我得到以下異常「無法推斷架構類型:」無法推斷架構類型:<類型「的unicode」>轉換時RDD到數據幀
例如:
>> rangeRDD.take(1).foreach(println)
(301,301,10)
>> sqlContext.inferSchema(rangeRDD)
Can not infer schema for type: <type 'unicode'>
任何指針如何解決它?我甚至嘗試注入架構自己在sqlContext.createDataFrame(RDD,架構)
schema = StructType([
StructField("x", IntegerType(), True),
StructField("y", IntegerType(), True),
StructField("z", IntegerType(), True)])
df = sqlContext.createDataFrame(rangeRDD, schema)
print df.first()
但在運行時錯誤結束了 'ValueError異常:意外的元組U'(301,301,10) '與StructType'