Answers for "pyspark udf multiple inputs"

Go
0

pyspark udf multiple inputs

from pyspark.sql.types import IntegerType
from pyspark.sql.functions import udf

def sum(x, y):
    return x + y

sum_cols = udf(sum, IntegerType())

a=spark.createDataFrame([(101, 1, 16)], ['ID', 'A', 'B'])
a.withColumn('Result', sum_cols('A', 'B')).show()
Posted by: Guest on August-18-2020

Code answers related to "pyspark udf multiple inputs"

Browse Popular Code Answers by Language