Convert numpy bins of the form [0,2,4,6,8,10] to a string format ideal for frequency chart tables ['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.0.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file compressbins-1.1.0.tar.gz
.
File metadata
- Download URL: compressbins-1.1.0.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 | b762a202443c6b7c4270f8bca06a6f99f636b95031497c8e828c6f4c7dc3a121 |
|
MD5 | c01733e0704cef899d004640f00df9d3 |
|
BLAKE2b-256 | 992b3110dbe96b9d0d01b867db02c70cfd57fcde04fbcc7f5b4f61a2d21d556e |
File details
Details for the file compressbins-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: compressbins-1.1.0-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 | 6693f208630e69acc62cb5ba049994871a044c3a2ff95439b49c5fded30dfa3f |
|
MD5 | 55abf79ff414f5d5c67631f8202c045a |
|
BLAKE2b-256 | 67eaa040abff40a1dab6f7a7421f8148b75bcdb730d08fe1b53a1f0934896348 |