pyspark.sql.functions.
levenshtein
Computes the Levenshtein distance of the two given strings.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
first column value.
second column value.
Levenshtein distance as integer value.
Examples
>>> df0 = spark.createDataFrame([('kitten', 'sitting',)], ['l', 'r']) >>> df0.select(levenshtein('l', 'r').alias('d')).collect() [Row(d=3)]