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.0.3.tar.gz (245.5 kB view details)

Uploaded Source

Built Distribution

labrea-2.0.3-py3-none-any.whl (44.8 kB view details)

Uploaded Python 3

File details

Details for the file labrea-2.0.3.tar.gz.

File metadata

  • Download URL: labrea-2.0.3.tar.gz
  • Upload date:
  • Size: 245.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for labrea-2.0.3.tar.gz
Algorithm Hash digest
SHA256 d4ffb5f0526cb3cc0f5edbda61ff671d5274cef0471fe3caba1d87fe7fa0c0a2
MD5 3c4bc0f6f854335e92e79d1896124094
BLAKE2b-256 2975e3d0a1c0cfe1e462682eaa363de37d49df4d7a176967245d5b4ec713ce6b

See more details on using hashes here.

Provenance

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

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

Attestations:

File details

Details for the file labrea-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: labrea-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 44.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for labrea-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 69c61f957d41b911bd5a081009baaaf3203790c5561cc71fc69402d46314cba2
MD5 b6d3f1863ca87304d04d77f740112a4f
BLAKE2b-256 b3872897af41820beb7a0f6077b137b4f6b1fbd8f9161b4bd84c9d8c1df20022

See more details on using hashes here.

Provenance

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

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

Attestations:

Supported by

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