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, pandas.Series, and pandas.DataFrames.

Features

  • Works with numbers, lists, pandas.Series, and pandas.DataFrames
  • 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

Bin a DataFrame column-wise

df = pd.DataFrame({"age": [21, 34, 65], "income": [2000, 3120, 4190]})
cut(df, binwidth=10)

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.1.1.tar.gz (2.6 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.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simplebins-0.1.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/24.4.0

File hashes

Hashes for simplebins-0.1.1.tar.gz
Algorithm Hash digest
SHA256 43f1419fc94341de6557d23c0dfbbdc62007a876e48076177ccb9fb1691928a6
MD5 db7183f972a4a198527a455253e4d0bc
BLAKE2b-256 0505c6c7d5a1e912ca61844dce0ec2701fe6b59c4c2b4b47519e5082d102f713

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simplebins-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/24.4.0

File hashes

Hashes for simplebins-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7fe339655bb1f65a096215811064df5def22f233df54df3bce34e5a707e11c1b
MD5 55cf39664fe030cd9c1c022f1c55cc4e
BLAKE2b-256 22871fd686ed730d5cbde902a24f7c0943265243f83ce3dd3650db6d99b499c6

See more details on using hashes here.

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