py-utilz
Convenient helper functions, decorators, and data analysis tools to make life easier with minimal dependencies:
pip install py-utilz
dplyr like data grammar:
from utilz import pipe
import utilz.dfverbs as _
out = pipe(
df,
_.rename({"weight (male, lbs)": "male", "weight (female, lbs)": "female"}),
_.pivot_longer(columns=["male", "female"], into=("sex", "weight")),
_.split("weight", ("min", "max"), sep="-"),
_.pivot_longer(columns=["min", "max"], into=("stat", "weight")),
_.astype({"weight": float}),
_.groupby("genus", "sex"),
_.mutate(weight="weight.mean()"),
_.pivot_wider(column="sex", using="weight"),
_.mutate(dimorphism="male / female")
)
from utilz import map
# Combine function results into a list, array, or dataframe
map(myfunc, myiterable)
# Syntactic sugar for joblib.Parallel
map(myfunc, myiterable, n_jobs=4)
from utilz import log, maybe
# Print the shape of args and outputs before and after execute
@log
def myfunc(args):
return out
# Only run myfunc if results.csv doesn't eist
@maybe
def myfunc(args, out_file=None):
return out
myfunc(args, out_file='results.csv')
Development
- Install poetry:
curl -sSL https://install.python-poetry.org | python - Setup virtual environment
poetry install --with dev - Run all tests:
poetry run pytest - Live render docs:
poetry run mkdocs serve
Additional poetry/virtual environment commands
- Activate environment in current shell:
source activate .venv/bin/activate - Activate environment in sub-process shell:
poetry shell - Add/remove additional packages:
poetry add/remove package_name - Build local package:
poetry build - Deploy to pypi:
poetry publish(requires auth)
Metadata
Release files for py-utilz 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_utilz-0.4.1.tar.gz | 44.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_utilz-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.5 kB
Release files / py_utilz-0.4.1.tar.gz
| Download URL | py_utilz-0.4.1.tar.gz |
|---|---|
| Size | 44.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71fbbbe37379b532a2eb2d018807c5dba6dee1f523e154b6c63cbb7d3abd92cb
|
|
BLAKE2b-256 checksum How to use checksums |
01721b30014b270c2f5d8b0facb85357971bc0c86ec2ef7c14363c0817dfae39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / py_utilz-0.4.1-py3-none-any.whl
| Download URL | py_utilz-0.4.1-py3-none-any.whl |
|---|---|
| Size | 54.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5c84943893012a5551e9de41cf752e46b8e5ebab16b5102dd04f553e90470d5
|
|
BLAKE2b-256 checksum How to use checksums |
bb24a79f1212100e9db17c42f2ebc09eeb9f24bd562e5fad21d41fd4aeefb415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|