StringMethods.edit_distance(targets) SeriesOrIndex[source]#

The targets strings are measured against the strings in this instance using the Levenshtein edit distance algorithm.

The targets parameter may also be a single string in which case the edit distance is computed for all the strings against that single string.

targetsarray-like, Sequence or Series or str

The string(s) to measure against each string.

Series or Index of int32.


>>> import cudf
>>> sr = cudf.Series(["puppy", "doggy", "kitty"])
>>> targets = cudf.Series(["pup", "dogie", "kitten"])
>>> sr.str.edit_distance(targets=targets)
0    2
1    2
2    2
dtype: int32
>>> sr.str.edit_distance("puppy")
0    0
1    4
2    4
dtype: int32