← string_distance operator page · string/string_distance/hamming_sc/three_differing_positions

Three differing positions 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

string_distance(hamming, SC_1, SC_2) with SC_1 = karolin and SC_2 = kathrin, two strings of the same length.

Manual:

String distances: "Returns the Hamming distance, which is the number of positions at which the corresponding characters are different. Both strings must have the same length."

Expected:

SC_r is 3, a Number: karolin and kathrin have 7 characters and differ at the 3rd (r and t), the 4th (o and h) and the 5th (l and r).

script.vtl ⇩

SC_r := string_distance(hamming, SC_1, SC_2);

input/scalars.csv ⇩

SC_1SC_2
karolinkathrin

input/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_1", "type": "String"},
    {"name": "SC_2", "type": "String"}
  ]
}

expected/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_r", "type": "Number", "value": 3}
  ]
}