You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A column mixing the number 1 and the string "1" gives two groups with the same label in Python and one group in JS #993
Where:faircode/profiler.py_dimension() (col.dropna().value_counts(), line 335), assets/profiler-engine.jsnunique() / the group counter, tests/test_json_edge_cases.py.
Current gap:value_counts() keeps the integer 1 and the string "1" apart, then _analyze_groups() stringifies the labels, so the report lists 1 twice. JS keys groups by their string form and shows one 1 group with the combined count. A JSON column that mixes types (common when one exporter quotes some numbers) is therefore profiled differently by the two engines, and the Python report has two rows a person cannot tell apart.
Repro:
$ python3 - <<'E'
import json, tempfile, os
from faircode.loaders_extra import read_table
from faircode import profile
p = os.path.join(tempfile.mkdtemp(), "m.json")
open(p, "w").write(json.dumps([{"race": v} for v in [1, "1", "a", "b"] * 10]))
print([(g["label"], g["count"]) for g in profile(read_table(p), {"race": "race"})["dimensions"][0]["groups"]])
E
[('1', 10), ('1', 10), ('a', 10), ('b', 10)] # JS: [('1', 20), ('a', 10), ('b', 10)]
Suggested approach: convert the column to strings before counting (after dropping nulls), so both engines key on the same text, and add a mixed-type JSON file to the parity tests.
Activity
fix: a number and its string form are one group in Python, as in the …
yakew7 commentedon Oct 16, 2026
Fixed in 0a3bb6d (on main). Full suite green (941 passed).