I defined a UDF and it will return 3 values. 1 is an integer value. 2 is a float value and 3 is a list.
mylist = [8,9.5,10,11,12]
def Calculat(mylist):
x = mylist[0]
y = mylist[1]
list = mylist[-3,-2,-1]
return x, y, list
Then I want to run this to define 3 types with this code
func = F.udf(lambda x: calculate(x), T.StructType(
[T.StructField("val1", T.IntegerType(), True),
T.StructField("val2", T.FloatType(), True),
T.StructField("val3", T.ListType(), True)]))
But I get this error
AttributeError: module 'pyspark.sql.types' has no attribute 'ListType'