Skip to main content

A framework for declarative, functional dataset definitions.

Project description

Labrea Logo

Labrea

A framework for declarative, functional dataset definitions.

lifecycle PyPI Downloads pre-commit Coverage docs

Installation

Labrea is available for install via pip.

pip install labrea

Alternatively, you can install the latest development version from GitHub.

pip install git+https://github.com/8451/labrea@develop

Usage

See our usage guide here.

Labrea exposes a dataset decorator that allows you to define datasets and their dependencies in a declarative manner. Dependencies can either be other datasets or Options, which are values that can be passed in at runtime via a dictionary.

from labrea import dataset, Option
import pandas as pd


@dataset
def stores(path: str = Option('PATHS.STORES')) -> pd.DataFrame:
    return pd.read_csv(path)


@dataset
def transactions(path: str = Option('PATHS.SALES')) -> pd.DataFrame:
    return pd.read_csv(path)


@dataset
def sales_by_region(
        stores_: pd.DataFrame = stores,
        transactions_: pd.DataFrame = transactions
) -> pd.DataFrame:
    """Merge stores to transactions, sum sales by region"""
    return pd.merge(transactions_, stores_, on='store_id').groupby('region')['sales'].sum().reset_index()


options = {
    'PATHS': {
        'STORES': 'path/to/stores.csv',
        'SALES': 'path/to/sales.csv'
    }
}


stores(options)
## +-----------------+-----------+
## | store_id        | region    |
## |-----------------+-----------|
## | 1               | North     |
## | 2               | North     |
## | 3               | South     |
## | 4               | South      |
## +-----------------+-----------+

transactions(options)
## +-----------------+-----------------+-----------------+
## | store_id        | sales           | transaction_id  |
## |-----------------+-----------------+-----------------|
## | 1               | 100             | 1               |
## | 2               | 200             | 2               |
## | 3               | 300             | 3               |
## | 4               | 400             | 4               |
## +-----------------+-----------------+-----------------+

sales_by_region(options)
## +-----------------+-----------------+
## | region          | sales           |
## |-----------------+-----------------|
## | North           | 300             |
## | South           | 700             |
## +-----------------+-----------------+

Contributing

If you would like to contribute to labrea, please read the Contributing Guide.

Changelog

A summary of recent updates to labrea can be found in the Changelog.

Maintainers

Maintainer Email
Austin Warner austin.warner@8451.com
Michael Stoepel michael.stoepel@8451.com

Links

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

labrea-2.1.0b3.tar.gz (253.1 kB view details)

Uploaded Source

Built Distribution

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

labrea-2.1.0b3-py3-none-any.whl (50.9 kB view details)

Uploaded Python 3

File details

Details for the file labrea-2.1.0b3.tar.gz.

File metadata

  • Download URL: labrea-2.1.0b3.tar.gz
  • Upload date:
  • Size: 253.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for labrea-2.1.0b3.tar.gz
Algorithm Hash digest
SHA256 697fb9022d1e64450a85720c1dde0d8644f8b9ffa880e6b91b373eca14d4769b
MD5 ecd17442441460244d680e106108132f
BLAKE2b-256 1c0cff6dc6327eb33b60ae2f3fc2497b5fbf458ea76cab3d76bc2c64f32466e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for labrea-2.1.0b3.tar.gz:

Publisher: build-and-deploy.yml on 8451/labrea

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file labrea-2.1.0b3-py3-none-any.whl.

File metadata

  • Download URL: labrea-2.1.0b3-py3-none-any.whl
  • Upload date:
  • Size: 50.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for labrea-2.1.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 8b47e4747fdb3b2cb1b172a3715a93b4d1b8d823f16d2a596ce022b7ff753afa
MD5 b1d7043a98251165fca63f28baa9c22d
BLAKE2b-256 e6ce75a13e76255e1d1e44838d4821c880ef82390a5bc8c1598dcb1c8a55f56b

See more details on using hashes here.

Provenance

The following attestation bundles were made for labrea-2.1.0b3-py3-none-any.whl:

Publisher: build-and-deploy.yml on 8451/labrea

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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