model_transformer
A small library aimed to help cleaning input json data, and allowing a more centered source of truth.
Installation
pip install model-transformer
Usage
This basic sample will show how to extract field name from input data, and how to create a calculated field age also from input data.
from datetime import datetime
from model_transformer import Transformer, Field
class SampleTransformer(Transformer):
name = Field("name") # This field will extract name from input data.
def get_age(self, row: dict) -> int:
birth = datetime.fromisoformat(row.get("birth"))
diff = datetime.now() - birth
return diff.days // 365
data = [
{
"name": "John Doe",
"birth": "1998-05-01T00:00:00",
"email": "john@company.com",
}
]
transformer = SampleTransformer()
transformer.transform(data)
#... [
#... {
#... "name": "John Doe",
#... "age": 25
#... }
#... ]
Metadata
Release files for model-transformer 0.2.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 | |
|---|---|---|---|
| model_transformer-0.2.0.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| model_transformer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.6 kB
Release files / model_transformer-0.2.0.tar.gz
| Download URL | model_transformer-0.2.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
141f2156ced076653d953f38cd5a4be9ae04f31105e3c0d8419fe65401554776
|
|
BLAKE2b-256 checksum How to use checksums |
b5bb61f17835ff31df8b2545ca11906046ec7f3bbb4e2147163967245daaad6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2
|
Release files / model_transformer-0.2.0-py3-none-any.whl
| Download URL | model_transformer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bcc908d552380a11f4227ce793b477a1e81f95c575518e7579c62bb4e84ad895
|
|
BLAKE2b-256 checksum How to use checksums |
deffc09a33d9bf3cd32ffa959b9354c06b75241929a801b6494a85675f4617d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2
|