应该是一个容易回答的问题......我这样做错了吗?我可以不投多列吗?
>>> 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
语法错误不断弹出逗号...
答案 0 :(得分:2)
试试这个。我认为这是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") )