ragrawal.wordpress.com
Reusable Spark Custom UDF
This post shows to write pyspark UDF that accepts additional arguments and can be used outside of pyspark context.