{"id":23397,"library":"categorical-distance","title":"categorical-distance","description":"Python library for measuring distances between categorical variables. Supports a variety of distance metrics including Hamming, Jaccard, and Dice coefficients. Version 1.9, stable.","status":"active","version":"1.9","language":"python","source_language":"en","source_url":"https://github.com/datamade/categorical-distance","tags":["categorical","distance","metrics","classification"],"install":[{"cmd":"pip install categorical-distance","lang":"bash","label":"Install"}],"dependencies":[{"reason":"Required for distance matrix computation","package":"scipy","optional":false},{"reason":"Used for array operations","package":"numpy","optional":false}],"imports":[{"note":"Direct import of module does not expose the function; must import the function explicitly.","wrong":"import categorical_distance","symbol":"categorical_distance","correct":"from categorical_distance import categorical_distance"},{"note":"Import the submodule directly as shown.","wrong":"import categorical_distance.metrics","symbol":"metrics","correct":"from categorical_distance import metrics"}],"quickstart":{"code":"from categorical_distance import categorical_distance\ndistance_matrix = categorical_distance(['a','b','c'], ['a','c','b'])\nprint(distance_matrix)","lang":"python","description":"Compute the distance matrix between two lists of categorical values."},"warnings":[{"fix":"Ensure input lists have the same length.","message":"The function `categorical_distance` expects lists or arrays of equal length; if lengths differ, it raises a ValueError.","severity":"gotcha","affected_versions":"all"},{"fix":"Preprocess data to remove or impute missing values before calling the function.","message":"The library does not handle missing values (NaN/None). Input must be clean categorical values.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `from categorical_distance import metrics` instead.","message":"The `distances` module is deprecated and has been replaced by `metrics`.","severity":"deprecated","affected_versions":"<1.6"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure both input lists have the same length.","cause":"Input sequences have different lengths.","error":"ValueError: arrays must have same length"},{"fix":"Use 'from categorical_distance import categorical_distance' to import the function.","cause":"Importing the module directly instead of the function.","error":"AttributeError: module 'categorical_distance' has no attribute 'categorical_distance'"},{"fix":"Run 'pip install categorical-distance'.","cause":"Library not installed.","error":"ImportError: No module named 'categorical_distance'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}