Easy, model based data wrangling.
Project description
wrangle_pypes
Easy, model based data wrangling.
Origin
This project came about thanks to having implemented this concept in a prior project (dfb_predict) and wanting to reuse it. In said previous project it came about, because we wanted to play around with data-oriented design and figured that if we break up the transformations required during data-wrangling/munging into a simple "AST" where each node represents a single transformation. And to further the idea we to some inspiration from one of the Unix philosophy core tenants, i.e. a single transformation should do one simple thing only, and allow for composition to implement more complex behavior.
Example
from dataclasses import dataclass
import json
from wrangle_pypes import Pipeline
from wrangle_pypes.transformations import Get, Create, Cast
@dataclass
class Point:
x: int
y: int
@dataclass
class Square:
A: Point
B: Point
pipeline = Pipline({
Square: {
"A": Get("A") | Create(Point),
"A": Get("B") | Create(Point),
},
Point: {
"x": Get("x") | Cast(int),
"y": Get("y") | Cast(int),
}
})
data = """
[
{
"A": {"x": 0, "y", 0},
"B": {"x": 1, "y", 1},
}, {
"A": {"x": 10, "y", 10},
"B": {"x": 11, "y", 11},
}
]
"""
squares = list(pipeline.create_multiple(json.loads(data)))
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
Hashes for wrangle_pypes-0.2.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a340f59824d7c2ed3c360e8f69e6a1032853b150aabd345c7611793eaaa9b57b |
|
MD5 | f940dcfcd1b437410ecca1b7cc4f5ee5 |
|
BLAKE2b-256 | ba50236727cef2669a052e7b6b6b1bbb61efe04334605739358e7531edb43bfe |
Hashes for wrangle_pypes-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b18be3627acc357c06c042af17f717952e42c11ddaebde9fd588e250bee243ae |
|
MD5 | 8fc10e5b8f0813cd06879b53e0ef3ab4 |
|
BLAKE2b-256 | f80267a5463612254a431c927e37964a16d5a0cc6a9c61a5317d8115f256e348 |