edit_distance

In [ ]:
edit_distance(expr1, 
              expr2,)

Calculates and returns the Levenshtein distance between the two strings.

Parameters

Name Type Optional Description
expr1
object
❌
Expression.
expr2
object
❌
Expression.

Returns

str_sql : SQL expression.

Example

In [1]:
from verticapy import *
df = tablesample({"x": ['hello', 'apple', 'heroes', 'allo']}).to_vdf()
display(df)
Abc
x
Varchar(6)
1hello
2apple
3heroes
4allo
Rows: 1-4 | Column: x | Type: varchar(6)
In [3]:
# Importing the stats module
import verticapy.stats as st

# Applying the week function
df["edit_distance_x"] = st.edit_distance(df["x"], 'heyllow')
display(df)
Abc
x
Varchar(6)
123
edit_distance_x
Integer
1hello2
2apple6
3heroes5
4allo4
Rows: 1-4 | Columns: 2