Pypelines-ETL
Simple library to make pipelines or ETL
Installation
$ pip install pypelines-etl
Usage
pypelines allows you to build ETL pipeline. For that, you simply need
the combination of an Extractor, some Transformer or Filter, and a Loader.
Extractor
Making an extractor is fairly easy. Simply decorate a function that return
the data with Extractor:
import pandas
from pypelines import Extractor
@Extractor
def read_iris_dataset(filepath: str) -> pandas.Dataframe:
return pandas.read_csv(filepath)
Transformer or Filter
The Transformer and Filter decorators are equivalent.
Making a Transformer or a Filter is even more easy:
import pandas
from pypelines import Filter, Transformer
@Filter
def keep_setosa(df: pandas.DataFrame) -> pandas.DataFrame:
return df[df['class'] == 'Iris-setosa']
@Filter
def keep_petal_length(df: pandas.DataFrame) -> pandas.Series:
return df['petallength']
@Transformer
def mean(series: pandas.Series) -> float:
return series.mean()
Note that it is possible to combine the Transformer and the Filter
to shorten the pipeline syntax. For example:
new_transformer = keep_setosa | keep_petal_length | mean
pipeline = read_iris_dataset('filepath.csv') | new_transformer
print(pipeline.value)
# 1.464
Loader
In order to build a Loader, it suffices to decorate a function that takes at
least one data parameter.
import json
from pypelines import Loader
@Loader
def write_to_json(output_filepath: str, data: float) -> None:
with open(output_filepath, 'w') as file:
json.dump({'mean-petal-lenght': {'value': data, 'units': 'cm'}}, file)
A Loader can be called without the data parameter,
which loads arguments (like an URL or a path). For example, calling write_to_json(output.json)
will not execute the function, but store the output_filepath argument until the Loader execution in a pipeline.
The standard execution of the function (with the data argument) is however still usable write_to_json(output.json, data=1.464).
ETL pipeline
To make and run the pipeline, simply combine the Extractor with the Transformer, the Filter and the Loader
read_iris_dataset('filepath.csv') | keep_setosa | keep_petal_length | mean | write_to_json('output.json')
Metadata
Release files for pypelines-etl 0.1.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 |
|---|---|---|---|---|
| pypelines-etl-0.1.0.tar.gz | 3.5 kB | Without provenance | Details for pypelines-etl-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypelines_etl-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pypelines_etl-0.1.0-py3-none-any.whl |
Total release size: 7.9 kB
Release files / pypelines-etl-0.1.0.tar.gz
| Download URL | pypelines-etl-0.1.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1087bf86f7916a2906af0d150fa1be1b98578db31d45f82594542b46fdc5d7e3
|
|
BLAKE2b-256 checksum How to use checksums |
be158edab0f202804119b5724b98357a9e51b2f3c2766a33c1088fe6e149be4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.9 CPython/3.7.5 Linux/5.8.15-201.fc32.x86_64
|
Release files / pypelines_etl-0.1.0-py3-none-any.whl
| Download URL | pypelines_etl-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba111ae86b316103a019c06058739d6e06b42369829db873560e1dd87879d7c1
|
|
BLAKE2b-256 checksum How to use checksums |
2b660056dbc12c0f40550166091a46b7b19b920684660c4a00c92a4acffef302
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.9 CPython/3.7.5 Linux/5.8.15-201.fc32.x86_64
|
Security for pypelines-etl 0.1.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.