A small Python library to detect and remove outliers from datasets.
Project description
cleanoutliers
A lightweight Python library to detect and remove outlier rows from arrays and DataFrames.
Features
- Remove outliers from NumPy arrays and pandas DataFrames.
- Multiple methods: IQR, Z-score, Modified Z-score.
- Optionally return the outlier mask for inspection.
Installation
pip install cleanoutliers
For pandas support:
pip install "cleanoutliers[pandas]"
Quick Start
import numpy as np
from cleanoutliers import remove_outliers
data = np.array([10, 11, 12, 13, 300])
cleaned = remove_outliers(data, method="iqr", threshold=1.5)
print(cleaned) # [10. 11. 12. 13.]
With pandas DataFrame
import pandas as pd
from cleanoutliers import remove_outliers
df = pd.DataFrame({"age": [20, 21, 22, 99], "score": [88, 90, 91, 89]})
clean_df = remove_outliers(df, method="iqr", columns=["age"])
API
detect_outliers(data, method="iqr", columns=None, threshold=1.5, z_threshold=3.0)
Returns a boolean mask where True means the row is an outlier.
remove_outliers(data, method="iqr", columns=None, threshold=1.5, z_threshold=3.0, return_mask=False)
Returns cleaned data with outlier rows removed.
If return_mask=True, returns (cleaned_data, outlier_mask).
Publish to PyPI
- Update metadata in
pyproject.toml(name, author, email). - Install publishing tools:
pip install -U build twine
- Build package:
python -m build
- Check distributions:
twine check dist/*
- Upload to TestPyPI (recommended first):
twine upload --repository testpypi dist/*
- Upload to PyPI:
twine upload dist/*
Publish with GitHub Trusted Publishing (No API Token)
This project includes GitHub Actions workflows for Trusted Publishing:
.github/workflows/publish-testpypi.yml.github/workflows/publish-pypi.yml
One-time setup on PyPI/TestPyPI
- Create accounts on PyPI and TestPyPI.
- In each project settings page, add a Trusted Publisher.
- Provider: GitHub.
- Fill in:
- GitHub owner/user
- Repository name
- Workflow filename (
publish-testpypi.ymlfor TestPyPI,publish-pypi.ymlfor PyPI) - Environment: leave empty unless you use one
Release flow
- Commit and push your changes to GitHub.
- For a TestPyPI pre-release, create a release-candidate tag:
git tag v0.1.0-rc1 git push origin v0.1.0-rc1
- For a PyPI release, create a stable tag:
git tag v0.1.0 git push origin v0.1.0
The corresponding GitHub workflow will build and publish automatically using OIDC.
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cleanoutliers-0.1.1.tar.gz.
File metadata
- Download URL: cleanoutliers-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15a3e2fb24c729ab894887ca86503934275a1267e789f5d0c77adff9b85673de
|
|
| MD5 |
65484b3b38679bfabbce14f475a0faca
|
|
| BLAKE2b-256 |
a4adafc90f544c2de4e94366c3d321049a742049f93d33c07373b6e61eafc24e
|
Provenance
The following attestation bundles were made for cleanoutliers-0.1.1.tar.gz:
Publisher:
publish-pypi.yml on Meetpatel21-pug/cleanset
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cleanoutliers-0.1.1.tar.gz -
Subject digest:
15a3e2fb24c729ab894887ca86503934275a1267e789f5d0c77adff9b85673de - Sigstore transparency entry: 1340159922
- Sigstore integration time:
-
Permalink:
Meetpatel21-pug/cleanset@4e938527e7d07b656e061f8f17da319a4419803a -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Meetpatel21-pug
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@4e938527e7d07b656e061f8f17da319a4419803a -
Trigger Event:
push
-
Statement type:
File details
Details for the file cleanoutliers-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cleanoutliers-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0b8cb8ad4d3e8653fd8a6a7142ef6cec3213aa593c10a81307c356d9b174cac
|
|
| MD5 |
0430c3ff22fe087733113bd7843a1115
|
|
| BLAKE2b-256 |
b59ca8ffd76c5c1a89b82db7009e67ffbcd34a6449fbb6511b477304e45a9128
|
Provenance
The following attestation bundles were made for cleanoutliers-0.1.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on Meetpatel21-pug/cleanset
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cleanoutliers-0.1.1-py3-none-any.whl -
Subject digest:
f0b8cb8ad4d3e8653fd8a6a7142ef6cec3213aa593c10a81307c356d9b174cac - Sigstore transparency entry: 1340159955
- Sigstore integration time:
-
Permalink:
Meetpatel21-pug/cleanset@4e938527e7d07b656e061f8f17da319a4419803a -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Meetpatel21-pug
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@4e938527e7d07b656e061f8f17da319a4419803a -
Trigger Event:
push
-
Statement type: