Skip to main content

fishersapi: An API for applying a fast Fisher's Exact Test to variable pairs in pandas DataFrames

Project description

fishersapi

Build Status

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

fishersapi-0.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

fishersapi-0.1.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file fishersapi-0.1.1.tar.gz.

File metadata

  • Download URL: fishersapi-0.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for fishersapi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 09f7ccfc11ab51cc2988c7d9a3491885cfb2bdbf2abf3daadaf421b0212c7e7d
MD5 5813fa1cca9354bc3a47ecf8cda24f73
BLAKE2b-256 786ec1edd41a87afcd9b2cffa1b920648060545487bc0a1db2b914054c65af39

See more details on using hashes here.

File details

Details for the file fishersapi-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fishersapi-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for fishersapi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e33ba5a9af3422c7c93871571e89670645f6c6db96df3b63620322dd98f19e9
MD5 ef83f181bc2837b65fad9fda52429508
BLAKE2b-256 7d1d0be3b9db4f9264a54eba79d8bbe1d6a2c25c4c5c5c0412c6be5318c30e90

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page