Registry / data / gower
library0.1.2pypypiunverified

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.

pip install gower
INSTALL
IMPORT
SIG · GOWER
G
gower
datapythonv0.1.2
Install
7.2s avg
Import
Disk
230MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 230.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 7.2s · import 0.000s · 222MB
230MB installed
● package 230MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gower_matrix
from gower import gower_matrix
from gower import gower_matrix

Compute pairwise Gower's distance between two dataframes with mixed numeric and categorical columns.

import numpy as np import pandas as pd from gower import gower_matrix # Example data with mixed types X = pd.DataFrame({ 'num': [1.0, 2.0, 3.0], 'cat': ['a', 'b', 'a'] }) Y = pd.DataFrame({ 'num': [2.0, 3.0], 'cat': ['b', 'c'] }) # Compute Gower's distance matrix D = gower_matrix(X, Y) print(D) # Expected: array of shape (len(X), len(Y))
Debug
Known issues
gotchaThe 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.
fix
Impute missing values before calling gower_matrix if a different handling is required.
affects: 0.1.2
gotchaThe 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.
fix
Ensure categorical columns are explicitly of dtype 'object' or 'category' (though category may not be recognized; prefer object dtype).
affects: 0.1.2
Upgrade
Version history
0.1.2latest on PyPI · released Nov 13, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
14
Resources
gower — pip install gower · libregistry