Skip to content

Transformation Functions API#

[source]

udf#

hopsworks.udf(return_type, drop=None, mode="default")

Create an User Defined Function that can be and used within the Hopsworks Feature Store to create transformation functions.

Hopsworks UDF's are user defined functions that executes as 'pandas_udf' when executing in spark engine and as pandas functions in the python engine. The pandas udf/pandas functions gets as inputs pandas Series's and can provide as output a pandas Series or a pandas DataFrame. A Hopsworks udf is defined using the hopsworks_udf decorator. The outputs of the defined UDF must be mentioned in the decorator as a list of python types.

Example

from hopsworks import udf

@udf(float)
def add_one(data1):
    return data1 + 1

Arguments

  • return_type List[type] | type: The output types of the defined UDF
  • drop str | List[str] | None: The features to be dropped after application of transformation functions

Returns

HopsworksUdf: The metadata object for hopsworks UDF's.

Raises

  • hsfs.client.exceptions.FeatureStoreException : If unable to create UDF.