Convert numpy bins of the form [0,2,4,6,8,10] to a string format ideal for creating frequency charts in the numpy-pandas ecosystem. ['0-2','2-4','4-6','6-8','8-10']
Project description
compress-bins
This package provides the compress_bins() function, a quality-of-life function for creating frequency charts in the numpy-pandas ecosystem.
Usage:
import compressbins.compressbins as cb
compressed_bins = cb.compress_bins([0,2,4,6])
print(compressed_bins) # ['0-2','2-4','4-6']
We can then use these sbins in creating frequency charts:
import pandas as pd
import numpy as np
counts, bins = np.histogram(df, bins=np.arange(10.00, 20.00, 1.00))
cbins = compress_bins(bins)
freqChart = pd.DataFrame({"Cost":cbins, "Count":counts})
print(freqChart)
Cost Count
0 10.0-11.0 1
1 11.0-12.0 8
2 12.0-13.0 16
3 13.0-14.0 9
4 14.0-15.0 6
5 15.0-16.0 4
6 16.0-17.0 3
7 17.0-18.0 2
8 18.0-19.0 1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
compressbins-1.1.1.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file compressbins-1.1.1.tar.gz
.
File metadata
- Download URL: compressbins-1.1.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f98a1486c7a51bdf7ed141be81c652e27c2d2e88a3283d4cecd884b486827798 |
|
MD5 | 42a458559fc982342b7c5ab541364200 |
|
BLAKE2b-256 | 4fd5cf397160e2234db2c97a7da58fbe643ed8f897afd3a87f4a8348000a3a07 |
File details
Details for the file compressbins-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: compressbins-1.1.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f67adbfef9dd6125c5413b4f1ba73b37bbf24e02062b4bb87163606648410b9 |
|
MD5 | dc472cea47809c0245f61d7d0a910580 |
|
BLAKE2b-256 | 1c295c103443daba6066675a9a7cf75e80902d660ee3b6c2484641ae45eeb9f1 |