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.3.tar.gz
.
File metadata
- Download URL: fishersapi-0.3.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2.post20200812 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeb63bb1661a14fea40d578acde051347c4b7e7472111131efeffd37fa3e0252 |
|
MD5 | 2468371de4d34b2857f2d341e3975450 |
|
BLAKE2b-256 | 9bb676f901e319fb10e31d89ebd47d45ebda9a1504676b6d5bc89908acae5caa |
File details
Details for the file fishersapi-0.3-py3-none-any.whl
.
File metadata
- Download URL: fishersapi-0.3-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2.post20200812 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39412abec4f93053d85b1963aef013c3b7aa34e3937bb920d8d61fe3f0826876 |
|
MD5 | f0b7f1bcb3b358cfc09b108e32661048 |
|
BLAKE2b-256 | cf13a606e7e648fa7157035514ee4cb6c4bbac235979a707d5d379227e4be39f |