我需要找到大约900列的行值之和我在这个链接中应用了这个函数
Spark - Sum of row values
from functools import reduce
def superSum(*cols):
return reduce(lambda a, b: a + b, cols)
add = udf(superSum)
df.withColumn('total', add(*[df[x] for x in df.columns])).show()
但我犯了这个错误
Py4JJavaError: An error occurred while calling o1005.showString.
: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1.0 failed 1 times, most recent failure: Lost task 0.0 in stage 1.0 (TID 1, localhost, executor driver): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
File "***********\pyspark\worker.py", line 218, in main
File "***********\pyspark\worker.py", line 147, in read_udfs
File "<string>", line 1
SyntaxError: more than 255 arguments