Skip to main content

A Python library for defining and applying column functions to DuckDB tables

Project description

Deductable

de-duck-table A way to deduce new columns in your duckdb table

Description

For a client I was doing research on a collection of websites. I wanted an easy way to add a column with findings based on the previous information. For instance, I started with a list of names, for which i didn't have the URL. An agent took in the name, and found the website url.

Installation

uv pip install deductable

Requirements

  • Python 3.13+
  • DuckDB 1.4.1+
  • Loguru 0.7.3+
  • Pandas 2.3.3+

Quick Start

from typing import Optional
import duckdb
from deductable import Deductable
from my_agents import find_url

# Connect to a DuckDB database
with duckdb.connect('companies.duckdb') as con:
    # Create a Deductable instance for the table
    # Deductable expects at least an id column
    dt = Deductable(con, table_name="companies")

    @dt.column
    def company_url(company_name: str) -> Optional[float]:
        # company_name should be a column in the duckdb
        return find_url(company_name)

    # Apply the column function to populate the weight column
    dt.materialize()

    # View the result
    print(dt.df())

Features

  • Type-safe column functions: Define column functions with proper type annotations
  • Automatic column creation: Columns are automatically created based on function names
  • Dependency handling: Functions can depend on other columns
  • Optional values: Support for nullable columns with Optional type annotations
  • Pandas integration: Easy conversion to pandas DataFrames

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

deductable-1.0.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

deductable-1.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file deductable-1.0.1.tar.gz.

File metadata

  • Download URL: deductable-1.0.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for deductable-1.0.1.tar.gz
Algorithm Hash digest
SHA256 362c990dcad42b4b18e432f9ad2d7d04da6a2c188e21f19a96fafa1b5f2db581
MD5 82ccde1f82beb19069b3a97f5578e996
BLAKE2b-256 f14ceeb61c90d649de4b348463e5419462bf8d514c2714f16d894a41949e945d

See more details on using hashes here.

File details

Details for the file deductable-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for deductable-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 910b4f1a842dc99b818edc02692532625b48c7fba07abba14816390fca6ef991
MD5 f79bb050325b2d0e49565423b4ece815
BLAKE2b-256 3bd9a7de5a1eafa3da85e6841a47d0fc86d3118a96a7491ec7b03a6d6bcd9dd8

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