mpu


Namempu JSON
Version 0.23.1 PyPI version JSON
download
home_pagehttps://github.com/MartinThoma/mpu
SummaryMartins Python Utilities
upload_time2020-06-23 18:46:24
maintainerMartin Thoma
docs_urlNone
authorMartin Thoma
requires_python>= 3.6
licenseMIT
keywords utility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            [![PyPI version](https://badge.fury.io/py/mpu.svg)](https://badge.fury.io/py/mpu)
[![Python Support](https://img.shields.io/pypi/pyversions/mpu.svg)](https://pypi.org/project/mpu/)
[![Documentation Status](https://readthedocs.org/projects/mpu/badge/?version=latest)](http://mpu.readthedocs.io/en/latest/?badge=latest)
[![Build Status](https://travis-ci.org/MartinThoma/mpu.svg?branch=master)](https://travis-ci.org/MartinThoma/mpu)
[![Coverage Status](https://coveralls.io/repos/github/MartinThoma/mpu/badge.svg?branch=master)](https://coveralls.io/github/MartinThoma/mpu?branch=master)

# mpu
Martins Python Utilities (mpu) is a collection of utility functions and classes
with no other dependencies.

The total size of the package will never be bigger than 10 MB and currently it
is 15.7 kB in zipped form. This makes it a candidate to include into AWS Lambda
projects.


## Installation

```bash
$ pip install git+https://github.com/MartinThoma/mpu.git
```

It can, of course, also be installed via PyPI.


## Usage

### Datastructures

```python-repl
>>> from mpu.datastructures import EList

>>> l = EList([2, 1, 0])
>>> l[2]
0

>>> l[[2, 0]]
[0, 2]

>>> l[l]
[0, 1, 2]
```

### Shell

To enhance your terminals output, you might want to do something like:

```python
from mpu.shell import Codes

print("{c.GREEN}{c.UNDERLINED}Works{c.RESET_ALL}".format(c=Codes))
```


### Quick Examples

Creating small example datastructures is a task I encounter once in a while
for StackExchange answers.

```python
from mpu.pd import example_df

df = example_df()
print(df)
```

gives

```
     country   population population_time    EUR
0    Germany   82521653.0      2016-12-01   True
1     France   66991000.0      2017-01-01   True
2  Indonesia  255461700.0      2017-01-01  False
3    Ireland    4761865.0             NaT   True
4      Spain   46549045.0      2017-06-01   True
5    Vatican          NaN             NaT   True
```


### Money

```python
import mpu
from fractions import Fraction

gross_income = mpu.units.Money("2345.10", "EUR")
net_income = gross_income * Fraction("0.80")
apartment = mpu.units.Money("501.23", "EUR")
savings = net_income - apartment
print(savings)
```

prints `1375.31 Euro`


### IO

* Download files with `mpu.io.download(source, sink)`
* Read CSV, JSON and pickle with `mpu.io.read(filepath)`
* Write CSV, JSON and pickle with `mpu.io.write(filepath, data)`



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MartinThoma/mpu",
    "name": "mpu",
    "maintainer": "Martin Thoma",
    "docs_url": null,
    "requires_python": ">= 3.6",
    "maintainer_email": "info@martin-thoma.de",
    "keywords": "utility",
    "author": "Martin Thoma",
    "author_email": "info@martin-thoma.de",
    "download_url": "https://files.pythonhosted.org/packages/f8/b2/8a346462daf65a6ed9ee41d9f8308f56ef83d0fd6778b144d7b5cd71193a/mpu-0.23.1.tar.gz",
    "platform": "Linux",
    "description": "[![PyPI version](https://badge.fury.io/py/mpu.svg)](https://badge.fury.io/py/mpu)\n[![Python Support](https://img.shields.io/pypi/pyversions/mpu.svg)](https://pypi.org/project/mpu/)\n[![Documentation Status](https://readthedocs.org/projects/mpu/badge/?version=latest)](http://mpu.readthedocs.io/en/latest/?badge=latest)\n[![Build Status](https://travis-ci.org/MartinThoma/mpu.svg?branch=master)](https://travis-ci.org/MartinThoma/mpu)\n[![Coverage Status](https://coveralls.io/repos/github/MartinThoma/mpu/badge.svg?branch=master)](https://coveralls.io/github/MartinThoma/mpu?branch=master)\n\n# mpu\nMartins Python Utilities (mpu) is a collection of utility functions and classes\nwith no other dependencies.\n\nThe total size of the package will never be bigger than 10 MB and currently it\nis 15.7 kB in zipped form. This makes it a candidate to include into AWS Lambda\nprojects.\n\n\n## Installation\n\n```bash\n$ pip install git+https://github.com/MartinThoma/mpu.git\n```\n\nIt can, of course, also be installed via PyPI.\n\n\n## Usage\n\n### Datastructures\n\n```python-repl\n>>> from mpu.datastructures import EList\n\n>>> l = EList([2, 1, 0])\n>>> l[2]\n0\n\n>>> l[[2, 0]]\n[0, 2]\n\n>>> l[l]\n[0, 1, 2]\n```\n\n### Shell\n\nTo enhance your terminals output, you might want to do something like:\n\n```python\nfrom mpu.shell import Codes\n\nprint(\"{c.GREEN}{c.UNDERLINED}Works{c.RESET_ALL}\".format(c=Codes))\n```\n\n\n### Quick Examples\n\nCreating small example datastructures is a task I encounter once in a while\nfor StackExchange answers.\n\n```python\nfrom mpu.pd import example_df\n\ndf = example_df()\nprint(df)\n```\n\ngives\n\n```\n     country   population population_time    EUR\n0    Germany   82521653.0      2016-12-01   True\n1     France   66991000.0      2017-01-01   True\n2  Indonesia  255461700.0      2017-01-01  False\n3    Ireland    4761865.0             NaT   True\n4      Spain   46549045.0      2017-06-01   True\n5    Vatican          NaN             NaT   True\n```\n\n\n### Money\n\n```python\nimport mpu\nfrom fractions import Fraction\n\ngross_income = mpu.units.Money(\"2345.10\", \"EUR\")\nnet_income = gross_income * Fraction(\"0.80\")\napartment = mpu.units.Money(\"501.23\", \"EUR\")\nsavings = net_income - apartment\nprint(savings)\n```\n\nprints `1375.31 Euro`\n\n\n### IO\n\n* Download files with `mpu.io.download(source, sink)`\n* Read CSV, JSON and pickle with `mpu.io.read(filepath)`\n* Write CSV, JSON and pickle with `mpu.io.write(filepath, data)`\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Martins Python Utilities",
    "version": "0.23.1",
    "split_keywords": [
        "utility"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a63ac4c04201c9cd8c5845f85915d644cb14b16200680e5fa424af01c411e140",
                "md5": "39376064f8d52a27b6fd49c7d7648f83",
                "sha256": "04a31c7db11202bbae23b8c81034a0e8a7b63784a9a7536435ceaf578ec0c094"
            },
            "downloads": -1,
            "filename": "mpu-0.23.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "39376064f8d52a27b6fd49c7d7648f83",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">= 3.6",
            "size": 69719,
            "upload_time": "2020-06-23T18:46:22",
            "upload_time_iso_8601": "2020-06-23T18:46:22.342620Z",
            "url": "https://files.pythonhosted.org/packages/a6/3a/c4c04201c9cd8c5845f85915d644cb14b16200680e5fa424af01c411e140/mpu-0.23.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f8b28a346462daf65a6ed9ee41d9f8308f56ef83d0fd6778b144d7b5cd71193a",
                "md5": "aac06ef2de0378b9946a319c209ca45d",
                "sha256": "93d6409d3556178e6fd24b90b151d60f2ddeea5b17844e0c615d802f5510395b"
            },
            "downloads": -1,
            "filename": "mpu-0.23.1.tar.gz",
            "has_sig": false,
            "md5_digest": "aac06ef2de0378b9946a319c209ca45d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">= 3.6",
            "size": 65366,
            "upload_time": "2020-06-23T18:46:24",
            "upload_time_iso_8601": "2020-06-23T18:46:24.393046Z",
            "url": "https://files.pythonhosted.org/packages/f8/b2/8a346462daf65a6ed9ee41d9f8308f56ef83d0fd6778b144d7b5cd71193a/mpu-0.23.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-06-23 18:46:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "MartinThoma",
    "github_project": "mpu",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": true,
    "circle": true,
    "requirements": [],
    "tox": true,
    "lcname": "mpu"
}
        
Elapsed time: 0.03324s