Skip to main content

Convert numpy bins to a string format ideal for creating frequency charts in the numpy-pandas ecosystem. Ex. [0, 2, 4, 6, 8, 10] -> ['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 compressed bins 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


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.2.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

compressbins-1.2.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file compressbins-1.2.0.tar.gz.

File metadata

  • Download URL: compressbins-1.2.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for compressbins-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ed8a12fc97dc0614bc359a2b1c6df42e078432ea916ba906f19a0a8e1fe9ffa0
MD5 cbc7deb290963a70b07dfe5b5d692e3a
BLAKE2b-256 f630e218fa2f1d842c3789237c0533b8d6dee5a4200bac558f7189eab5052635

See more details on using hashes here.

File details

Details for the file compressbins-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for compressbins-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa15a290af00ffae1a08c9c27b1349f01fbfce34d7e8d6983acd937c7a89b10f
MD5 ba612f73a2431c461ebc2afb4262c875
BLAKE2b-256 ebfc220569be259319aeeae3a1489a887b246a0303c0cead79a84553af450327

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page