Skip to main content

A dependency-free library to quickly make ascii/text histograms from data.

Project description

text_histogram

PyPI version Number of PyPI downloads

Histograms are great for exploring data, but numpy and matplotlib are heavy and overkill for quick analysis. They also can’t be easily used on remote servers over ssh. Don’t even get me started on installing them.

Bit.ly’s data_hacks histogram.py is great but difficult to use from python code directly (it requires an optparse.OptionParser to pass histogram options). This is histogram.py repackaged for convenient script use.

Python 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from text_histogram import histogram
>>> histogram([1, 2, 2, 2, 2, 3, 3, 3], graph_char='#')
# NumSamples = 8; Min = 1.00; Max = 3.00
# Mean = 2.250000; Variance = 0.437500; SD = 0.661438; Median 2.000000
# each # represents a count of 1
     1.0000 -      1.2000 [     1]: #
     1.2000 -      1.4000 [     0]:
     1.4000 -      1.6000 [     0]:
     1.6000 -      1.8000 [     0]:
     1.8000 -      2.0000 [     4]: ####
     2.0000 -      2.2000 [     0]:
     2.2000 -      2.4000 [     0]:
     2.4000 -      2.6000 [     0]:
     2.6000 -      2.8000 [     0]:
     2.8000 -      3.0000 [     3]: ###
>>> histogram([1, 2, 2, 2, 2, 3, 3, 3], graph_char='#', display_empty_buckets=False)
# NumSamples = 8; Min = 1.00; Max = 3.00
# Mean = 2.250000; Variance = 0.437500; SD = 0.661438; Median 2.000000
# each # represents a count of 1
     1.0000 -      1.2000 [     1]: #
     1.8000 -      2.0000 [     4]: ####
     2.8000 -      3.0000 [     3]: ###

Installation

pip uninstall text_histogram text_histogram3  # avoid conflicts
pip install text_histogram32

Source: https://github.com/clach04/text_histogram32

Fork of https://github.com/Kobold/text_histogram with a few tweaks:

  • Same name space as original text_histogram

  • Python 3 and 2.7 support

  • Support for control over character used for the bar (see graph_char and DEFAULT_graph_char option)

  • Support for NOT displaying empty buckets/bins/intervals (see display_empty_buckets and DEFAULT_display_empty_buckets option)

  • Fixes

ToDo items

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

text_histogram32-0.0.7.tar.gz (5.4 kB view hashes)

Uploaded Source

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