Dataframe: Row(r)函数是什么?

huangapple go评论59阅读模式
英文:

Dataframe: Row(r) function?

问题

我正在阅读官方的Spark示例,并使用Pyspark。我在以下代码中遇到了一个错误NameError: name 'Row' is not defined。这个函数需要进行一些外部导入吗?

df = textFile.map(lambda r: Row(r)).collect()
英文:

I'm reading the official Spark examples and using Pyspark. I'm getting an error NameError: name 'Row' is not defined with the following code. Is there some external import required for this function?

df = textFile.map(lambda r: Row(r)).collect()

答案1

得分: 0

将以下代码添加到你的代码中:

from pyspark.sql import Row

请注意,这是一个示例,你需要根据你的实际情况进行相应的修改。

英文:

Add import Row from pyspark.sql library to your code.

Example:

from pyspark.sql import Row

huangapple
  • 本文由 发表于 2023年8月8日 21:43:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76860151.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定