如何从dict创建Dataframe?我使用以下代码并遇到错误。
from pyspark import SparkContext, SQLContext
sc = SparkContext.getOrCreate()
spark = SQLContext(sc)
result_dict = {'a':3,'b':44}
data = list(map(list, result_dict.items()))
f_rdd = spark.createDataFrame(data, ["A", "B"]).repartition(1)
错误:
AttributeError Traceback (most recent call last)
<ipython-input-10-a25453caa1c3> in <module>
5 result_dict = {'a':3,'b':44}
6 data = list(map(list, result_dict.items()))
----> 7 f_rdd = spark.createDataFrame(data, ["A", "B"]).repartition(1)
AttributeError: 'SQLContext' object has no attribute 'createDataFrame'
1条答案
按热度按时间q3aa05251#
你可以这样试试