{"id":15009428,"url":"https://github.com/martinthoma/mpu","last_synced_at":"2025-05-10T20:05:46.374Z","repository":{"id":32017247,"uuid":"131384072","full_name":"MartinThoma/mpu","owner":"MartinThoma","description":"Martins Python Utilities - Stuff that comes in Handy","archived":false,"fork":false,"pushed_at":"2022-12-08T13:38:32.000Z","size":500,"stargazers_count":60,"open_issues_count":18,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-10T20:05:41.679Z","etag":null,"topics":["python","python-3-6","python-3-7","python-3-8","python3","utility","utility-library"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MartinThoma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-28T07:17:23.000Z","updated_at":"2024-12-02T23:37:38.000Z","dependencies_parsed_at":"2023-01-14T20:20:36.354Z","dependency_job_id":null,"html_url":"https://github.com/MartinThoma/mpu","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Fmpu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Fmpu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Fmpu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Fmpu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MartinThoma","download_url":"https://codeload.github.com/MartinThoma/mpu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253474215,"owners_count":21914227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","python-3-6","python-3-7","python-3-8","python3","utility","utility-library"],"created_at":"2024-09-24T19:25:13.575Z","updated_at":"2025-05-10T20:05:46.300Z","avatar_url":"https://github.com/MartinThoma.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![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[![MartinThoma](https://circleci.com/gh/MartinThoma/mpu.svg?style=shield)](https://app.circleci.com/pipelines/github/MartinThoma/mpu)\n[![Build Status](https://dev.azure.com/martinthoma/mpu/_apis/build/status/MartinThoma.mpu?branchName=master)](https://dev.azure.com/martinthoma/mpu/_build/latest?definitionId=1\u0026branchName=master)\n[![Coverage Status](https://coveralls.io/repos/github/MartinThoma/mpu/badge.svg?branch=master)](https://coveralls.io/github/MartinThoma/mpu?branch=master)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n![GitHub last commit](https://img.shields.io/github/last-commit/MartinThoma/mpu)\n![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/MartinThoma/mpu/0.23.1)\n[![CodeFactor](https://www.codefactor.io/repository/github/martinthoma/mpu/badge/master)](https://www.codefactor.io/repository/github/martinthoma/mpu/overview/master)\n[![mutmut](https://pypi.org/project/mutmut/)](https://img.shields.io/badge/mutmut-1417%2F1813-lightgrey)\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 120 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\u003e\u003e\u003e from mpu.datastructures import EList\n\n\u003e\u003e\u003e l = EList([2, 1, 0])\n\u003e\u003e\u003e l[2]\n0\n\n\u003e\u003e\u003e l[[2, 0]]\n[0, 2]\n\n\u003e\u003e\u003e 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)`](https://mpu.readthedocs.io/en/latest/io.html#mpu.io.download).\n* Read CSV, JSON and pickle with [`mpu.io.read(filepath)`](https://mpu.readthedocs.io/en/latest/io.html#mpu.io.write).\n* Write CSV, JSON and pickle with [`mpu.io.write(filepath, data)`](https://mpu.readthedocs.io/en/latest/io.html#mpu.io.read)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinthoma%2Fmpu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinthoma%2Fmpu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinthoma%2Fmpu/lists"}