Skip to main content

PyPI version Python Support Documentation Status Build Status Coverage Status

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

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

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

Usage

Datastructures

>>> 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:

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.

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

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)

Metadata

Release files for mpu 0.23.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpu 0.23.1
File Size Uploaded
mpu-0.23.1.tar.gz 65.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mpu 0.23.1
File Interpreter ABI Platform
mpu-0.23.1-py3-none-any.whl Python 3 none any Details

Total release size: 135.1 kB

Release files / mpu-0.23.1.tar.gz

Download URL mpu-0.23.1.tar.gz
Size 65.4 kB
Tags Source
SHA-256 checksum
How to use checksums
93d6409d3556178e6fd24b90b151d60f2ddeea5b17844e0c615d802f5510395b
BLAKE2b-256 checksum
How to use checksums
f8b28a346462daf65a6ed9ee41d9f8308f56ef83d0fd6778b144d7b5cd71193a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

Release files / mpu-0.23.1-py3-none-any.whl

Download URL mpu-0.23.1-py3-none-any.whl
Size 69.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04a31c7db11202bbae23b8c81034a0e8a7b63784a9a7536435ceaf578ec0c094
BLAKE2b-256 checksum
How to use checksums
a63ac4c04201c9cd8c5845f85915d644cb14b16200680e5fa424af01c411e140
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.23.1 This release

2 release files

0.20.0

2 release files

0.19.1

1 release file

0.19.0

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.15.1

2 release files

0.15.0

2 release files

0.14.2

2 release files

0.14.1

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page