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.
- 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
pandasandnumpy
pandas.cut() is powerful but sometimes overkill.
simplebins simplifies the common use case: fixed-width bins with predictable, numeric output – perfect for quick transformations.
pip install simplebinsfrom simplebins import cutcut(12, binwidth=5)
# Output: 10cut([3, 7, 12], binwidth=5)
# Output: [0, 5, 10]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