Firelink is based on scikit-learn pipeline and adding the functionality to store the pipeline in `.yaml` or `.ember` file for production.
Project description
Firelink
Firelink is based on scikit-learn pipeline and adding the functionality to store the pipeline in .yaml
or .ember
file for production.
Quickstart
Installation
pip install firelink
Basic Usage
import pandas as pd
from pandas.testing import assert_frame_equal
from firelink.transform import Drop_duplicates, Filter
from firelink.pipeline import FirePipeline
df = pd.DataFrame(
{
"a": range(10),
"b": range(10, 20),
"c": range(20, 30),
"d": ["a", "n", "d", "f", "g", "h", "h", "j", "q", "w"],
"e": ["a", "d", "a", "d", "e", "e", "a", "a", "d", "d"],
}
)
trans_1 = Filter(["a", "e"])
trans_2 = Drop_duplicates(["e"], keep="first")
pipe_1 = FirePipeline(
[("filter column a and e", trans_1), ("drop duplicate for column e", trans_2)]
)
pipe_1.save_fire("pipe_1.ember", file_type="ember")
pipe_2 = FirePipeline.link_fire("pipe_1.ember")
df1 = pipe_1.fit_transform(df)
df2 = pipe_2.fit_transform(df)
assert_frame_equal(df1, df2)
Spark Usage
import pandas as pd
from pandas.testing import assert_frame_equal
from firelink.spark_transform import WithColumn
from firelink.transform import Assign
from firelink.pipeline import FirePipeline
from pyspark.sql import SparkSession, functions as F
spark = SparkSession.builder.appName("spark_session").enableHiveSupport().getOrCreate()
df = pd.DataFrame({"col1": [1, 2, 3], "col2": ["a", "b", "c"]})
sdf = spark.createDataFrame(df)
add1 = WithColumn("Country", "F.lit('Canada')")
add2 = WithColumn("City", "F.lit('Toronto')")
spark_pipe = FirePipeline([("Add Country", add1), ("Add City", add2)])
# set_config(display="diagram")
# set_config(display="text")
spark_pipe
sdf = spark_pipe.fit_transform(sdf)
sdf.show()
add1 = Assign(**{"Country": "Canada"})
add2 = Assign(**{"City": "Toronto"})
pandas_pipe = FirePipeline([("Add Country", add1), ("Add City", add2)])
pandas_pipe.fit_transform(df)
assert_frame_equal(sdf.toPandas(), pandas_pipe.fit_transform(df))
Detailed Documentation
For the detailed documentation, please go through this portal.
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
firelink-0.1.1.tar.gz
(16.5 kB
view details)
Built Distribution
firelink-0.1.1-py3-none-any.whl
(10.5 kB
view details)
File details
Details for the file firelink-0.1.1.tar.gz
.
File metadata
- Download URL: firelink-0.1.1.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dee9105a3698ac705a8885ebf80dd2b9168446873a48e870003172dd4804968 |
|
MD5 | e23766e292195ee7be7e1630a11800d6 |
|
BLAKE2b-256 | e3446d0b2db25008b89e2e95b27b90acbf97cc43cb7cb77590d23d03ee48357b |
File details
Details for the file firelink-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: firelink-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0049be9b5d34c3fd60e9ec2948263dbe9ab9016b4681a58774565285f6549a51 |
|
MD5 | 2b6e1af0d142d8e359918b692cc926a8 |
|
BLAKE2b-256 | 307b40d26cc7fdeda2277414be7ad3bb8430d8260cff28cf02d3a7989eecc28e |