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()
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dvpipe-0.0.4.tar.gz.
File metadata
- Download URL: dvpipe-0.0.4.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.5.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe33c4a4852782d7ab055247eaa177cb68b6ca3042e1fed0e44112d0d5884489
|
|
| MD5 |
1b64ed566b812c40d23e7919d51da6c1
|
|
| BLAKE2b-256 |
e42ebefbc121e8f61a60a510bdc66aaeab815149b37e342b74470c0a2b02b017
|
File details
Details for the file dvpipe-0.0.4-py3-none-any.whl.
File metadata
- Download URL: dvpipe-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.5.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80b0f969baa2a556a35800cdc818f4acc61aa2747aa3f9c0fddbcef69f215448
|
|
| MD5 |
bb28de4f5bbb9035ff060b1ee4458870
|
|
| BLAKE2b-256 |
959e28f7a40a5c457287bd8d29efbee7a08ae3e6d7561d80b9ebf60f65eddd88
|