Skip to main content

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

  1. Update metadata in pyproject.toml (name, author, email).
  2. Install publishing tools:
    pip install -U build twine
    
  3. Build package:
    python -m build
    
  4. Check distributions:
    twine check dist/*
    
  5. Upload to TestPyPI (recommended first):
    twine upload --repository testpypi dist/*
    
  6. 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

  1. Create accounts on PyPI and TestPyPI.
  2. In each project settings page, add a Trusted Publisher.
  3. Provider: GitHub.
  4. Fill in:
    • GitHub owner/user
    • Repository name
    • Workflow filename (publish-testpypi.yml for TestPyPI, publish-pypi.yml for PyPI)
    • Environment: leave empty unless you use one

Release flow

  1. Commit and push your changes to GitHub.
  2. For a TestPyPI pre-release, create a release-candidate tag:
    git tag v0.1.0-rc1
    git push origin v0.1.0-rc1
    
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cleanoutliers-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cleanoutliers-0.1.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

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

Hashes for cleanoutliers-0.1.1.tar.gz
Algorithm Hash digest
SHA256 15a3e2fb24c729ab894887ca86503934275a1267e789f5d0c77adff9b85673de
MD5 65484b3b38679bfabbce14f475a0faca
BLAKE2b-256 a4adafc90f544c2de4e94366c3d321049a742049f93d33c07373b6e61eafc24e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cleanoutliers-0.1.1.tar.gz:

Publisher: publish-pypi.yml on Meetpatel21-pug/cleanset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for cleanoutliers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0b8cb8ad4d3e8653fd8a6a7142ef6cec3213aa593c10a81307c356d9b174cac
MD5 0430c3ff22fe087733113bd7843a1115
BLAKE2b-256 b59ca8ffd76c5c1a89b82db7009e67ffbcd34a6449fbb6511b477304e45a9128

See more details on using hashes here.

Provenance

The following attestation bundles were made for cleanoutliers-0.1.1-py3-none-any.whl:

Publisher: publish-pypi.yml on Meetpatel21-pug/cleanset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page