Coefficient of Variation (CV) and Coefficient of Quartile Variation (CQV) with Confidence Intervals (CI)
Project description
pycvcqv
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
- Install Poetry:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
- 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)
- Add the correct Path to
PATH
:
$env:PATH = "C:\Users\YourUsername\AppData\Roaming\Python\Scripts;" + $env:PATH
- Verify poetry installation:
poetry --version
- Create and activate a new virtual environment:
python -m venv .venv
.\.venv\Scripts\activate
- Install required libraries:
poetry lock -n; poetry export --without-hashes > requirements.txt
poetry install -n
- Type check with mypy
poetry run mypy --install-types --non-interactive pycvcqv/ tests/
- Unit tests and coverage
poetry run pytest --cov-report term --cov pycvcqv tests/
poetry run coverage-badge -o assets/images/coverage.svg -f
- Lint
poetry run pylint pycvcqv
- 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
- Safety check
poetry check
poetry run safety check --policy-file safety_policy.yml
poetry run bandit -ll --configfile pyproject.toml --recursive pycvcqv tests
- Creating badges data
.\.shell\badges.ps1
- 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
This project was generated with python-package-template
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
pycvcqv-0.1.13-py3-none-any.whl
(13.3 kB
view hashes)