|
| 1 | +ulist |
| 2 | +===== |
| 3 | + |
| 4 | +|PyPI| |License| |CI| |doc| |publish| |code style| |Coverage| |
| 5 | + |
| 6 | +`Documentation <https://tushushu.github.io/ulist/>`__ \| `Source |
| 7 | +Code <https://github.com/tushushu/ulist>`__ |
| 8 | + |
| 9 | +What |
| 10 | +~~~~ |
| 11 | + |
| 12 | +| Ulist is an ultra fast list/array data structure written in Rust with |
| 13 | + Python bindings. It aims to be the fundamental package for processing |
| 14 | + and computing 1-D list/array in Python. |
| 15 | +| It provides: |
| 16 | +
|
| 17 | +- an efficient, flexible and expressive 1-D list/array object; |
| 18 | +- broadcasting methods; |
| 19 | +- a SQL-like and method-chaining programming experience; |
| 20 | + |
| 21 | +Performance |
| 22 | +~~~~~~~~~~~ |
| 23 | + |
| 24 | +| Ulist is extremly fast, and even compared with libraries like Numpy. |
| 25 | + It is |
| 26 | +- more efficient on the ``string`` and ``boolean`` array, |
| 27 | +- same level efficient on the ``integer`` array, |
| 28 | +- and a bit slower on the ``floating`` array. |
| 29 | + |
| 30 | +Faster than Numpy is not the target of writing this repo, because they are just two different libraries. Ulist is more focused on general domain rather than just data science/machine learning/AI, for example the Linear Algebra Computation is not provided. But if you are curious about the performance, please see the `benchmarking results <https://github.com/tushushu/ulist/blob/main/benchmark.md>`__. |
| 31 | + |
| 32 | +Requirements |
| 33 | +~~~~~~~~~~~~ |
| 34 | + |
| 35 | +- Python: 3.7+ |
| 36 | +- OS: Linux, MacOS and Windows |
| 37 | + |
| 38 | +Installation |
| 39 | +~~~~~~~~~~~~ |
| 40 | + |
| 41 | +Run ``pip install ulist`` |
| 42 | + |
| 43 | +Examples |
| 44 | +~~~~~~~~ |
| 45 | + |
| 46 | +Count the number of items in bins. |
| 47 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 48 | + |
| 49 | +Given an array ``arr``, count the number of items in bins [0, 3), [3, 6), [6, 9) and [9, +inf). The ``result`` is a Python dictionary with bin names as keys and numbers as values. |
| 50 | + |
| 51 | +.. code:: python |
| 52 | +
|
| 53 | + >>> import ulist as ul |
| 54 | +
|
| 55 | + >>> arr = ul.arange(12) |
| 56 | + >>> arr |
| 57 | + UltraFastList([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) |
| 58 | +
|
| 59 | + >>> result = arr.case(default='[9, +inf)')\ |
| 60 | + ... .when(lambda x: x < 3, then='[0, 3)')\ |
| 61 | + ... .when(lambda x: x < 6, then='[3, 6)')\ |
| 62 | + ... .when(lambda x: x < 9, then='[6, 9)')\ |
| 63 | + ... .end()\ |
| 64 | + ... .counter() |
| 65 | + >>> result |
| 66 | + {'[3, 6)': 3, '[9, +inf)': 3, '[6, 9)': 3, '[0, 3)': 3} |
| 67 | +
|
| 68 | +Dot product. |
| 69 | +^^^^^^^^^^^^ |
| 70 | + |
| 71 | +Given two 1-D arrays and calculate the dot product result of those arrays. |
| 72 | + |
| 73 | +.. code:: python |
| 74 | +
|
| 75 | + >>> import ulist as ul |
| 76 | +
|
| 77 | + >>> arr = ul.from_seq(range(1, 4), dtype='float') |
| 78 | + >>> arr |
| 79 | + UltraFastList([1.0, 2.0, 3.0]) |
| 80 | +
|
| 81 | + >>> result = arr.mul(arr).sum() |
| 82 | + >>> result |
| 83 | + 14.0 |
| 84 | +
|
| 85 | +Rate of adults. |
| 86 | +^^^^^^^^^^^^^^^ |
| 87 | + |
| 88 | +Given the ages of people as ``arr``, and suppose the adults are equal or above 18. Clean the data by removing abnormal values and then calculate the rate of adults. |
| 89 | + |
| 90 | +.. code:: python |
| 91 | +
|
| 92 | + >>> import ulist as ul |
| 93 | +
|
| 94 | + >>> arr = ul.from_seq([-1, 10, 15, 20, 30, 50, 70, 80, 100, 200], dtype='int') |
| 95 | + >>> result = arr.where(lambda x: (x >= 0) & (x < 120))\ |
| 96 | + ... .apply(lambda x: x >= 18)\ |
| 97 | + ... .mean() |
| 98 | + >>> result |
| 99 | + 0.75 |
| 100 | +
|
| 101 | +Contribute |
| 102 | +~~~~~~~~~~ |
| 103 | + |
| 104 | +All contributions are welcome. See `Developer Guide <https://github.com/tushushu/ulist/blob/main/develop.md>`__ |
| 105 | + |
| 106 | +.. |PyPI| image:: https://badge.fury.io/py/ulist.svg |
| 107 | + :target: https://pypi.org/project/ulist/ |
| 108 | +.. |License| image:: https://img.shields.io/github/license/tushushu/ulist |
| 109 | + :target: https://github.com/tushushu/ulist/blob/main/LICENSE |
| 110 | +.. |CI| image:: https://github.com/tushushu/ulist/actions/workflows/main.yml/badge.svg?branch=0.9.0 |
| 111 | + :target: https://github.com/tushushu/ulist/actions/workflows/main.yml |
| 112 | +.. |doc| image:: https://github.com/tushushu/ulist/actions/workflows/sphinx.yml/badge.svg?branch=0.9.0 |
| 113 | + :target: https://github.com/tushushu/ulist/actions/workflows/sphinx.yml |
| 114 | +.. |publish| image:: https://github.com/tushushu/ulist/actions/workflows/publish.yml/badge.svg?branch=0.9.0 |
| 115 | + :target: https://github.com/tushushu/ulist/actions/workflows/publish.yml |
| 116 | +.. |code style| image:: https://img.shields.io/badge/style-flake8-blue |
| 117 | + :target: https://github.com/PyCQA/flake8 |
| 118 | +.. |Coverage| image:: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/tushushu/3a76a8f4c0d25c24b840fe66a3cf44c1/raw/metacov.json |
| 119 | + :target: https://github.com/tushushu/ulist/actions/workflows/coverage.yml |
0 commit comments