Snippets Collections
import pyspark.sql.types as T
@udf(returnType=T.ArrayType(T.ArrayType(T.DoubleType())))
def aad():
	return [[1.22]]

df.withColumn("new_col", aad(F.col()))
star

Mon Dec 12 2022 15:41:23 GMT+0000 (Coordinated Universal Time) https://sparkbyexamples.com/pyspark/pyspark-udf-user-defined-function/

#udf #pyspark

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension