prep-flow: Data preprocessing framework with type validation for data scientists.
Project description
prep-flow
Data preprocessing framework with type validation for data scientists.
What is it?
prep-flow is a framework for declaratively describing data preprocessing, which is a common task in the field of data science.
Data preprocessing using pandas often leads to procedural code and tends to be low readability and maintainability.
prep-flow solves this problem and provides declarative and highly readable code.
Install
$> pip install prep-flow
A Simple Example
from datetime import datetime
import pandas as pd
from prep_flow import BaseFlow, Column, String, Integer, DateTime, modifier, creator
df_member = pd.DataFrame({
"name": ["Taro Yamada", "John Smith", "Li Wei", "Hanako Tanaka"],
"gender": ["man", "man", "man", "woman"],
"birthday": ["1995/10/19", "1990/03/20", "2003/02/01", "1985/11/18"],
})
class MemberFlow(BaseFlow):
name = Column(dtype=String, name="name", description='Add "Mr." or "Ms." depending on the gender.')
gender = Column(dtype=String, category=["man", "woman"])
birthday = Column(dtype=DateTime)
age = Column(dtype=Integer)
@modifier("name")
def modify_name(self, data: pd.DataFrame) -> pd.Series:
data["prefix"] = data["gender"].apply(lambda x: "Mr." if x == "man" else "Ms.")
return data["prefix"] + data["name"]
@creator("age")
def create_age(self, data: pd.DataFrame) -> pd.Series:
return data["birthday"].apply(lambda x: (datetime.now() - x).days // 365)
member = MemberFlow(df_member)
print(member.data)
| name | gender | birthday | age |
|---|---|---|---|
| Mr.Taro Yamada | man | 1995/10/19 | 28 |
| Mr.John Smith | man | 1990/03/20 | 34 |
| Mr.Li Wei | man | 2003/02/01 | 21 |
| Ms.Hanako Tanaka | woman | 1985/11/18 | 38 |
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 prep_flow-0.1.2.tar.gz.
File metadata
- Download URL: prep_flow-0.1.2.tar.gz
- Upload date:
- Size: 31.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4833248b333c53168055535ab533277c943c8a9eb72139485c88f992e56ede0
|
|
| MD5 |
1d4938b7ae386c46b897b8282b9e9c7f
|
|
| BLAKE2b-256 |
fcb496d4220b42df2e67a3aafe4aba82d024cab2556d9f949fb2dad040ae591a
|
File details
Details for the file prep_flow-0.1.2-py3-none-any.whl.
File metadata
- Download URL: prep_flow-0.1.2-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f86d1dd1fe290babcb327506b6373d1b3d52b7f4823ce65f6297a1ef502a4653
|
|
| MD5 |
5189b921d771ba32d499c87ffb56ce94
|
|
| BLAKE2b-256 |
777bf1659d78dd328fb8c696bbdd05a4c860e1a53a761fbf6e98f3a060bde608
|