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.3.tar.gz (7.5 kB view details)

Uploaded Source

Built Distributions

fishersapi-0.1.3-py3.7.egg (18.0 kB view details)

Uploaded Source

fishersapi-0.1.3-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fishersapi-0.1.3.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for fishersapi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d0f71ab28a0828d0d97a9d5cdfa6653ca9ca1edaf90faf0b1ba85e07461884a1
MD5 3c13204f11b878952bee05e7abab2ea8
BLAKE2b-256 dd69225b821dc2c95147fbcad78d986b25fb59732b29f8ac61e79861291372e1

See more details on using hashes here.

File details

Details for the file fishersapi-0.1.3-py3.7.egg.

File metadata

  • Download URL: fishersapi-0.1.3-py3.7.egg
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for fishersapi-0.1.3-py3.7.egg
Algorithm Hash digest
SHA256 23d48025cd334feda9f60b8d448a32f6c4d96263d833d763c71bfd35a407aa40
MD5 44fa266fa8dcd4b5586c3bfd07327c95
BLAKE2b-256 49c4042ddb95c8001c93ec28bc58e0416186149da23a1f4aad41a01be8082fae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fishersapi-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for fishersapi-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b388e23f8ca17398dce03f87959dc599a8deb75e181e43aa9c31c30e37800d4a
MD5 dcf4e4ebe600116202269202b2d7c5f9
BLAKE2b-256 ba86a794cbd99bdb52485ee62d7fa051feddd287fd790a32348b944d11ee30be

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