from pyspark.sql.functions import UserDefinedFunction
from pyspark.sql.types import DoubleType
udf = UserDefinedFunction(numpy.random.normal, DoubleType())
Functions from Python packages for udf() of Spark dataframe