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
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 | |