Python Data Pipeline
Process any type of data in your projects easily, control the flow of your data!
Installation
Install smart-pipeline with:
pip install -U smart-pipeline
Usage
Package 'smart_pipeline' provides a Pipeline class:
# Import Pipeline class
from smart_pipeline import Pipeline
# Create an instance
pl = Pipeline()
Pipeline class has 3 types of pipes: item, data and stat.
Item pipe modifies each item in dataset without changing the whole population of data:
data = [1,2,3,4,5]
# Define an item function
def addOne(item):
return item + 1
# Adds function into pipeline
pl.addItemPipe(addOne)
# Pass the data through pipeline
res = pl(data)
# res = [2,3,4,5,6]
Data pipe is a filter:
data = [1,2,3,4,5]
def onlyOdd(item):
return False if item%2==0 else True
pl.addDataPipe(onlyOdd)
res = pl(data)
# res = [1,3,5]
Stat pipe reduces over the data, passing the accumulated value to each element:
data = [1,2,3,4,5]
# Function that goes over all items in dataset
def countNumberStat(stats, item):
stats["total"] += 1
if item%2==0:
stats["even"] += 1
else:
stats["odd"] += 1
return stats
# Function to be called at the end with accumulated stats
def printNumberStat(stats):
print(stats["total"], "items were processed in total.")
print(stats["even"], "of them are even.")
print(stats["odd"], "of them are odd")
# Make sure to pass initial state as 3rd argument
pl.addStatPipe(countNumberStat, printNumberStat, { "total":0, "even":0, "odd":0 })
pl(data)
# Output:
# 5 items were processed in total.
# 2 of them are even.
# 3 of them are odd
Check out some examples
If this library solved some of your problems, please consider starring the project 😉
And feel free to create pull requests!
Metadata
Release files for smart-pipeline 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smart_pipeline-1.0.0.tar.gz | 3.1 kB | Without provenance | Details for smart_pipeline-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smart_pipeline-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for smart_pipeline-1.0.0-py3-none-any.whl |
Total release size: 10.5 kB
Release files / smart_pipeline-1.0.0.tar.gz
| Download URL | smart_pipeline-1.0.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a4fe02a5450a6efa906924ef6b8d275699c033c2f418674ed79202a2993e4fb
|
|
BLAKE2b-256 checksum How to use checksums |
e6887367105dc64f6dd5212234edbc8a0c43a906ad08ddf1d6fbb06347c23828
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / smart_pipeline-1.0.0-py3-none-any.whl
| Download URL | smart_pipeline-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d23804fd937b0e81bf3daaa52b6097531235cde394bf570222ec5e820306b9f
|
|
BLAKE2b-256 checksum How to use checksums |
b623253ed58f9727a83a5dbc013cfeb1649151662f49c308e0193ab8c8df1ff0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for smart-pipeline 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.