Skip to main content

A small Python utility that pipes data from function to function in sequencial order.

Project description

dvpipe

A small Python utility for piping data from function to function in sequential order.

dvpipe allows you to pass data from function to function sequentially as you would in tradional method chaining. You can use dvpipe to transform any type of data not just DataFrames as with DataFrame.pipe()

Version License

Installation

$ pip install dvpipe

Usage

processed_data = pipe(data, func_a, func_b, func_c, ...)

Example

from dvpipe import pipe

data = (pipe(data,
             clean,
             transform,
             aggregate))

Why?

dvpipe attempts to help solve this classic problem seen in many data tranformation applications to allow for cleaner, more understandable code.

data = clean(data)
data = transform(data)
data = aggregate(data)

Functions with Arguments

Use Python tuples for functions with parameters.

df = pipe(df, (replace_foo, 'bar'))

Full Example

from dvpipe import pipe

raw_data = {'foo': 1, 'bar': 2}

def subtract_foo(data):
    data['foo'] = data['foo'] - 1
    return data

def add_bar(data):
    data['bar'] = data['bar'] + 1
    return data

def add_entry(data, entry):
    data.update(entry)
    return data

data = (pipe(raw_data,
             subtract_foo,
             add_bar,
             (add_entry, {'foobar': 5})))

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

dvpipe-0.0.4.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

dvpipe-0.0.4-py3-none-any.whl (3.7 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