gpt4 book ai didi

python - 如何修复此错误 : "SQLContext object has no no attribute ' jsonFile'

转载 作者:太空宇宙 更新时间:2023-11-03 15:47:17 24 4
gpt4 key购买 nike

我现在正在学习Spark。当我尝试加载json文件时,如下:

people=sqlContext.jsonFile("C:\wdchentxt\CustomerData.json")

我收到以下错误:

AttributeError: 'SQLContext' object has no attribute 'jsonFile'

我在 Windows 7 PC 上运行此程序,使用 Spark-2.1.0-bin-hadoop2.7 和 Python 2.7.13(2016 年 12 月 17 日)。

感谢您提出的任何建议。

最佳答案

您可能忘记导入隐式。这就是我的 Scala 解决方案:

def loadJson(filename: String, sqlContext: SqlContext): Dataset[Row] = {
import sqlContext._
import sqlContext.implicits._
val df = sqlContext.read.json(filename)
df
}

关于python - 如何修复此错误 : "SQLContext object has no no attribute ' jsonFile',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41641749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com