{"id":23805,"library":"gower","title":"Gower","description":"Python implementation of Gower's distance for mixed numerical and categorical data, computing pairwise distances between records in two datasets. Version 0.1.2 is the current and only release, with no active development since 2020. Requires Python >=2.7.","status":"active","version":"0.1.2","language":"python","source_language":"en","source_url":"https://github.com/wwwjk366/gower","tags":["gower","distance","mixed data","categorical","numerical","pairwise"],"install":[{"cmd":"pip install gower","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"gower_matrix is a function inside the gower module, not a module itself.","wrong":"import gower_matrix","symbol":"gower_matrix","correct":"from gower import gower_matrix"}],"quickstart":{"code":"import numpy as np\nimport pandas as pd\nfrom gower import gower_matrix\n\n# Example data with mixed types\nX = pd.DataFrame({\n    'num': [1.0, 2.0, 3.0],\n    'cat': ['a', 'b', 'a']\n})\nY = pd.DataFrame({\n    'num': [2.0, 3.0],\n    'cat': ['b', 'c']\n})\n\n# Compute Gower's distance matrix\nD = gower_matrix(X, Y)\nprint(D)\n# Expected: array of shape (len(X), len(Y))","lang":"python","description":"Compute pairwise Gower's distance between two dataframes with mixed numeric and categorical columns."},"warnings":[{"fix":"Impute missing values before calling gower_matrix if a different handling is required.","message":"The library handles missing values (NaN) by ignoring the feature for that pair (distance contribution set to 0). This may not be expected; no parameter to change this behaviour.","severity":"gotcha","affected_versions":"0.1.2"},{"fix":"Ensure categorical columns are explicitly of dtype 'object' or 'category' (though category may not be recognized; prefer object dtype).","message":"The categorical column handling is based on pandas object dtype. If your categorical columns are encoded as numbers (e.g., int64), they will be treated as numeric, which may produce incorrect distances.","severity":"gotcha","affected_versions":"0.1.2"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from gower import gower_matrix` and call `gower_matrix(X, Y)`.","cause":"Incorrect import: attempting to use `import gower; gower.gower(...)` instead of the correct `from gower import gower_matrix`.","error":"AttributeError: module 'gower' has no attribute 'gower'"},{"fix":"If you have a single feature, reshape to 2D: `X[['col']]` or `X.values.reshape(-1, 1)`.","cause":"Passing a 1D array or Series as input. The function expects 2D array-like (DataFrame or 2D numpy array).","error":"ValueError: Data must be 2-dimensional"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}