Skip to main content

A lightweight Python package to discretize numeric values into bins, similar to pandas.cut(), but simpler and more intuitive.

Project description

simplebins

simplebins is a lightweight Python utility that makes it easy to bin numeric values into equal-width intervals.
It supports individual numbers, lists and pandas.Series.

Features

  • Works with numbers, lists and pandas.Series
  • Returns either the bin index, floor, ceiling, midpoint, or a human-readable label
  • Clean and intuitive API
  • Handles missing values gracefully
  • Zero dependencies outside of pandas and numpy

Why not pandas.cut()?

pandas.cut() is powerful but sometimes overkill.
simplebins simplifies the common use case: fixed-width bins with predictable, numeric output – perfect for quick transformations.

Installation

pip install simplebins

Usage

from simplebins import cut

Bin a single number

cut(12, binwidth=5)
# Output: 10

Bin a list of numbers

cut([3, 7, 12], binwidth=5)
# Output: [0, 5, 10]

Bin a pandas Series

import pandas as pd
import numpy as np
cut(pd.Series([3, 7, np.nan]), binwidth=5)
# Output: 
# 0     0
# 1     5
# 2    nan
# dtype: object

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

simplebins-0.3.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

simplebins-0.3.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file simplebins-0.3.1.tar.gz.

File metadata

  • Download URL: simplebins-0.3.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for simplebins-0.3.1.tar.gz
Algorithm Hash digest
SHA256 88a08df07f2e9eb7cd1d12acd17cfcc03fcdaf0b654d62136ae1bb320e7aff61
MD5 118194b23e3efdd602a094ee2da1d56d
BLAKE2b-256 fcb791af45464579629aaa39be4af2e1dae1c898b4ece9cee5349785bcdced2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplebins-0.3.1.tar.gz:

Publisher: release.yml on mariuzka/simplebins

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

File details

Details for the file simplebins-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: simplebins-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for simplebins-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0302fdc4e13ed1ca88181078a3fd1265944d3aee13aeb6ae6c9b87ec626ac445
MD5 0808ef4d6a901091bbae0660d5937465
BLAKE2b-256 f2da95b5192f5ca5f52d3768838ff1253bd5f042754d304ad5d764c83879e6a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplebins-0.3.1-py3-none-any.whl:

Publisher: release.yml on mariuzka/simplebins

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