Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prep_flow-0.1.1.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prep_flow-0.1.1-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file prep_flow-0.1.1.tar.gz.

File metadata

  • Download URL: prep_flow-0.1.1.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

Hashes for prep_flow-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f0f02dc079c16acc046e77f510c62e7bcfac2712c2da259b201bb129e038ec6a
MD5 dc58db74c6ce5568dc57ffc53f44a55b
BLAKE2b-256 033018806eadd7e7006336ac6efa79dc022939e6d5faf7fde134c5830dfc4e28

See more details on using hashes here.

File details

Details for the file prep_flow-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: prep_flow-0.1.1-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

Hashes for prep_flow-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f82fa8654d541095d1d24c5d10260b8cd6ae19f5f2de7eb98b4c607e0034856
MD5 82bb3fe2adb20477fcfb9bf05c75cb6d
BLAKE2b-256 b1d99268a8d110d3385d173e226843b13ddf00065496f88ff7128467c878d052

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page