Skip to main content

Martins Python Utilities

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpu-0.16.0.tar.gz (48.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpu-0.16.0-py3-none-any.whl (56.3 kB view details)

Uploaded Python 3

File details

Details for the file mpu-0.16.0.tar.gz.

File metadata

  • Download URL: mpu-0.16.0.tar.gz
  • Upload date:
  • Size: 48.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

File hashes

Hashes for mpu-0.16.0.tar.gz
Algorithm Hash digest
SHA256 18d2f20462ef5555d48b2fe8ddc1600376e75b904422cf66a33671da459643aa
MD5 49079c2531ef5383d07b73299c34beb9
BLAKE2b-256 674ec29a7e63a4f3f00ccc20629dcce1d9b1eb44420350f67deea5037d981dfe

See more details on using hashes here.

File details

Details for the file mpu-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: mpu-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 56.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

File hashes

Hashes for mpu-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01218a1f53313fe117c9976120830b2fa0839b1f732db586cefce1d388cdc1e2
MD5 aba9657a74ebfcdc1885693e6efd7121
BLAKE2b-256 95591993b64f8f4fa137e97bd6aff240b0cc5bd4f03358c654fa99cca8405111

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page