Skip to main content

Faster, easier, more robust python data analysis

Project description

py-utilz

Build Status Coverage Status Python Versions Platforms

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

  1. Install poetry: curl -sSL https://install.python-poetry.org | python
  2. Setup virtual environment poetry install --with dev
  3. Run all tests: poetry run pytest
  4. 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)

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

py_utilz-0.4.1.tar.gz (44.9 kB view hashes)

Uploaded Source

Built Distribution

py_utilz-0.4.1-py3-none-any.whl (54.5 kB view hashes)

Uploaded Python 3

Supported by

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