Apache spark 如何在Apache Spark中使用select()转换?

Apache spark 如何在Apache Spark中使用select()转换?,apache-spark,pyspark,Apache Spark,Pyspark,我正在学习edX上的Spark入门课程。然而,我不能理解的事情很少,下面是一个实验任务。仅供参考,我不是在寻找解决方案 我无法理解为什么我会收到错误 TypeError:“列”对象不可调用 下面是代码 from pyspark.sql.functions import regexp_replace, trim, col, lower def removePunctuation(column): """ Args: column (Column): A Colum

我正在学习edX上的Spark入门课程。然而,我不能理解的事情很少,下面是一个实验任务。仅供参考,我不是在寻找解决方案

我无法理解为什么我会收到错误

TypeError:“列”对象不可调用

下面是代码

from pyspark.sql.functions import regexp_replace, trim, col, lower
def removePunctuation(column):
    """

    Args:
        column (Column): A Column containing a sentence.

    """

    # This following is giving error. I believe I am calling all the rows from the dataframe 'column' where the attribute is named as 'sentence'
    result = column.select('sentence') 

    return result

sentenceDF = sqlContext.createDataFrame([('Hi, you!',),
                                         (' No under_score!',),
                                         (' *      Remove punctuation then spaces  * ',)], ['sentence'])
sentenceDF.show(truncate=False)
(sentenceDF
 .select(removePunctuation(col('sentence')))
 .show(truncate=False))

你能说得详细一点吗?蒂亚

列参数不是DataFrame对象,因此无法访问select方法。您需要使用其他函数来解决此问题


提示:查看import语句

否决投票的原因?