我做了研究,但没有找到相关信息。我想要把一个简单的 pandas.DataFrame
转换成一个 Spark dataframe,就像这样:
df = pd.DataFrame({'col1': ['a', 'b', 'c'], 'col2': [1, 2, 3]})
sc_sql.createDataFrame(df, schema=df.columns.tolist())
我收到的错误消息是:
TypeError: Can not infer schema for type: <class 'str'>
我尝试了更简单的方法:
df = pd.DataFrame([1, 2, 3])
sc_sql.createDataFrame(df)
我得到了:
TypeError: Can not infer schema for type: <class 'numpy.int64'>
需要帮助吗?需要手动指定模式或其他吗?
sc_sql
是pyspark.sql.SQLContext
,我在Python 3.4和Spark 1.6的Jupyter笔记本中。
谢谢!
0.18.1
版本。 - neocortex0.18.1
),现在似乎可以工作了!显然,我之前使用的是旧版本,这就是问题所在。感谢您的帮助! - neocortex