Skip to main content

Coefficient of Variation (CV) and Coefficient of Quartile Variation (CQV) with Confidence Intervals (CI)

Project description

pycvcqv

PyPI Python Version Build status coverage report Downloads "Buy Me A Coffee"

static analysis vulnerabilities maintainability complexity lint report docstring

Code style: black Security: bandit Pre-commit License

Coefficient of Variation (CV) and Coefficient of Quartile Variation (CQV) with Confidence Intervals (CI)

Python port of cvcqv

Introduction

pycvcqv provides some easy-to-use functions to calculate the Coefficient of Variation (cv) and Coefficient of Quartile Variation (cqv) with confidence intervals provided with all available methods.

Install

pip install pycvcqv

Usage

import pandas as pd
from pycvcqv import coefficient_of_variation, cqv

coefficient_of_variation(
    data=[0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4, 4.6, 5.4, 5.4],
    multiplier=100,
)
# 64.6467
cqv(
    data=[0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4, 4.6, 5.4, 5.4],
    multiplier=100,
)
# 51.7241
data = pd.DataFrame(
    {
        "col-1": pd.Series([0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5]),
        "col-2": pd.Series([5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9]),
    }
)
coefficient_of_variation(data=data, num_threads=3)
#   columns      cv
# 0   col-1  0.6076
# 1   col-2  0.1359
cqv(data=data, num_threads=-1)
#   columns      cqv
# 0   col-1  0.3889
# 1   col-2  0.0732

For contributors

Testing

Linux

export PATH="$HOME/.poetry/bin:$PATH"
make install
make pre-commit-install
pre-commit run --all-files
make test && make coverage && make check-codestyle && make mypy && make check-safety && make extrabadges
pre-commit run --all-files

Windows

  1. Install Poetry:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
  1. Find the poetry installation directory:
C:\Users\YourUsername\AppData\Roaming\Python\Scripts
C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX\Scripts (where XX is the Python version)
  1. Add the correct Path to PATH:
$env:PATH = "C:\Users\YourUsername\AppData\Roaming\Python\Scripts;" + $env:PATH
  1. Verify poetry installation:
poetry --version
  1. Create and activate a new virtual environment:
python -m venv .venv
.\.venv\Scripts\activate
  1. Install required libraries:
poetry lock -n; poetry export --without-hashes > requirements.txt
poetry install -n
  1. Type check with mypy
poetry run mypy --install-types --non-interactive pycvcqv/ tests/
  1. Unit tests and coverage
poetry run pytest --cov-report term --cov pycvcqv tests/
poetry run coverage-badge -o assets/images/coverage.svg -f
  1. Lint
poetry run pylint pycvcqv
  1. Code-style check
poetry run pyupgrade --exit-zero-even-if-changed --py37-plus
poetry run isort --diff --check-only --settings-path pyproject.toml ./
poetry run black --diff --check --config pyproject.toml ./
poetry run darglint --verbosity 2 pycvcqv tests
poetry run interrogate -v pycvcqv
  1. Safety check
poetry check
poetry run safety check --policy-file safety_policy.yml
poetry run bandit -ll --configfile pyproject.toml --recursive pycvcqv tests
  1. Creating badges data
.\.shell\badges.ps1
  1. Upload to pypi
pip install twine
pip install --upgrade build

Upload code to GitHub

git pull
pre-commit run --all-files
git add .
git commit -m ":tada: Initial commit"
git push -u origin main

Credits

🚀 Your next Python package needs a bleeding-edge project structure.
This project was generated with python-package-template

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

pycvcqv-0.1.13.tar.gz (10.3 kB view hashes)

Uploaded Source

Built Distribution

pycvcqv-0.1.13-py3-none-any.whl (13.3 kB view hashes)

Uploaded Python 3

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