施放多列astype



应该很容易回答问题...我做错了吗?我不能施放多列吗?

>>> val results2 = results.select( results["HCAHPS Base Score"].cast(IntegerType).as(results["HCAHPS Base Score"]), results["HCAHPS Consistency Score"].cast(IntegerType).as(results["HCAHPS Consistency Score"]) )
File "<stdin>", line 1
val results2 = results.select( results["HCAHPS Base Score"].cast(IntegerType).as(results["HCAHPS Base Score"]), results["HCAHPS Consistency Score"].cast(IntegerType).as(results["HCAHPS Consistency Score"]) )
               ^
SyntaxError: invalid syntax

语法错误在逗号周围不断弹出...

尝试一下。我认为这是Pyspark,因为问题在PySpark

下标记
results2 = results.select( results["HCAHPS Base Score"].cast(IntegerType()).alias("HCAHPS Base Score"), results["HCAHPS Consistency Score"].cast(IntegerType()).alias("HCAHPS Consistency Score") )

在Scala中,您可以尝试以下。

val results2 = results.select( results["HCAHPS Base Score"].cast(IntegerType).as("HCAHPS Base Score"), results["HCAHPS Consistency Score"].cast(IntegerType).as("HCAHPS Consistency Score") )

相关内容

  • 没有找到相关文章

最新更新