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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fishersapi-0.1.2.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.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.2.tar.gz
Algorithm Hash digest
SHA256 9390b3aa60ca19908ab53437fd7b5e15c07897099c7e560572ab83993901302b
MD5 ecb3b1c4324764ab740f9be10c9977e7
BLAKE2b-256 107655de9f8f4d26f999a6f8ae87c19c29146c724a01d387bfd8eb312fda368e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fishersapi-0.1.2-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.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 92527036062d97888548710d9a8d337c95353cbe18f1d84c9860949a46db16f8
MD5 fefc8303ac7dd3156d5048140c4b6788
BLAKE2b-256 2dc77c73342f0039d05c4b212efc37829f34fc1abefdfbee583586be703bc59a

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