fishersapi: An API for applying a fast Fisher's Exact Test to variable pairs in pandas DataFrames
Project description
fishersapi
A package for applying a fast implementation of Fisher's exact test to observations in a pandas DataFrame.
Contingency tables are computed based on all pairs of columns in cols and all pairs of unique values within the columns.
The results are tested against scipy.stats.fishers_exact and fallback on scipy if the faster brentp/fishers_exact_test (~1000x faster) is not installed.
The fast version of the test is computed using the package fisher
developed by Haibao Tang and Brent Pedersen, which uses cython.
Installation
The package is compatible with Python 2.7 or Python 3.6 and can be installed from PyPI or cloned and installed directly.
pip install fishersapi
Example
import fishersapi
n = 50
df = pd.DataFrame({'VA':np.random.choice(['TRAV14', 'TRAV12', 'TRAV3', 'TRAV23', 'TRAV11', 'TRAV6'], n),
'JA':np.random.choice(['TRAJ4', 'TRAJ2', 'TRAJ3','TRAJ5', 'TRAJ21', 'TRAJ13'], n),
'VB':np.random.choice(['TRBV14', 'TRBV12', 'TRBV3', 'TRBV23', 'TRBV11', 'TRBV6'], n),
'JB':np.random.choice(['TRBJ4', 'TRBJ2', 'TRBJ3','TRBJ5', 'TRBJ21', 'TRBJ13'], n)})
df = df.assign(Count=1)
df.loc[:10, 'Count'] = 15
res = fishersapi.fishers_frame(df, ['VA', 'JA', 'VB', 'JB'], count_col=None, alternative='two-sided')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fishersapi-0.5.tar.gz
.
File metadata
- Download URL: fishersapi-0.5.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.2 importlib-metadata/4.6.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e15e6aed5ce2e59b40ae757726aa6903eaf4a05732fa1fdee0a43d848d5b9b0d |
|
MD5 | 86bc6a2e6cdb7134da09bd687e4bf23f |
|
BLAKE2b-256 | 587523d34ed8069e5ef8bcb9663fb13e8bc99ddfc5c9d69c80612ca13aa41592 |
File details
Details for the file fishersapi-0.5-py3-none-any.whl
.
File metadata
- Download URL: fishersapi-0.5-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.2 importlib-metadata/4.6.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ec2072f80fd437678c034aac1a72fdf2203becbca7c0fd1d83ffd9f3bc09b67 |
|
MD5 | 4738e7b20bf8b174ce4c0e62197d30b8 |
|
BLAKE2b-256 | ee6bf562f21ed6f6dc8e4abbefe4db053f37646f6319ff12b6264506847d2feb |