Skip to content
forked from mthh/jenkspy

Compute Natural Breaks in Python (Fisher-Jenks algorithm)

License

Notifications You must be signed in to change notification settings

awabasher/jenkspy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast Jenks breaks for Python

Compute "natural breaks" (Fisher-Jenks algorithm) on list/tuple/numpy.ndarray of integers/floats.

Intented compatibility: CPython 2.7+ and 3.4+

Wheels are provided via PyPI for windows users - Also available on conda-forge channel for Anaconda users

Version Anaconda-Server Badge Build Status travis Build status appveyor PyPI download month

Usage :

>>> import jenkspy
>>> import random
>>> list_of_values = [random.random()*5000 for _ in range(12000)]

>>> breaks = jenkspy.jenks_breaks(list_of_values, nb_class=6)

>>> breaks
    (0.1259707312994962, 1270.571003315598, 2527.460251085392, 3763.0374498649376, 4999.87456576267)

>>> import json
>>> with open('tests/test.json', 'r') as f:
...     data = json.loads(f.read())
...
>>> jenkspy.jenks_breaks(data, nb_class=5)
(0.0028109620325267315, 2.0935479691252112, 4.205495140049607, 6.178148351609707, 8.09175917180255, 9.997982932254672)

Installation

  • From pypi
pip install jenkspy
  • From source
git clone http://github.com/mthh/jenkspy
cd jenkspy/
python setup.py install
  • For anaconda users
conda install -c conda-forge jenkspy

Requirements (only for building from source):

  • C compiler
  • Python C headers

Motivation :

  • Making a painless installing C extension so it could be used more easily as a dependency in an other package (and so learning how to build wheels using appveyor).
  • Getting the break values! (and fast!). No fancy functionnality provided, but contributions/forks/etc are welcome.
  • Other python implementations are currently existing.

About

Compute Natural Breaks in Python (Fisher-Jenks algorithm)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 42.3%
  • PowerShell 32.6%
  • Batchfile 15.2%
  • C 9.9%