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.2.1.tar.gz (2.5 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.2.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for simplebins-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cb8c9216f83553dbcd69b5c474f808f3605991fb0cc36599493d0cd4cff202fb
MD5 24d457507f34c06f297013d8237ead01
BLAKE2b-256 fcbf608c38e155bb38b691c2bbdcf9c7f8eb509ba023181a6bf0cc9dd932a963

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplebins-0.2.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.2.1-py3-none-any.whl.

File metadata

  • Download URL: simplebins-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7ec35f76044aa9d4eedaeb082cc5044ca2f83646e9185368bd6493693d66c7df
MD5 b72e43095a391df37c3fa82df8979770
BLAKE2b-256 f01590a4a93cd5d92d6d4368e7e0947aa62f984b3161f324950b4bb5f01417a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplebins-0.2.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