daft.functions.hamming_distance_str#
hamming_distance_str #
hamming_distance_str(left: Expression, right: Expression) -> Expression
Compute the character-level Hamming distance between two strings.
The Hamming distance is the number of positions at which the corresponding characters are different.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left | Expression | The left string expression to compare. | required |
right | Expression | The right string expression to compare against. | required |
Returns:
| Type | Description |
|---|---|
Expression | The Hamming distance for each pair of strings. Returns null when either input |
Expression | is null or the two strings have different lengths. |
Examples:
1 2 3 4 5 | |
╭────────┬─────────┬──────────╮
│ x ┆ y ┆ distance │
│ --- ┆ --- ┆ --- │
│ String ┆ String ┆ Int64 │
╞════════╪═════════╪══════════╡
│ ronald ┆ ronald ┆ 0 │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
│ ronald ┆ renuld ┆ 2 │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
│ ronald ┆ ronaldo ┆ None │
╰────────┴─────────┴──────────╯
(Showing first 3 of 3 rows) Source code in daft/functions/str.py
1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 | |