mcpField
I
ibis-data

ibis-data

github.com/brojonatData & databases146 installsUpdated 2w ago
Repository

About ibis-data

Ibis Data Interface describes Ibis's database-agnostic Python DataFrame API for Python users doing data analysis and database development. It builds lazy expressions and translates them into SQL for the connected backend.

Key features

  1. 01Use a unified Python DataFrame API
  2. 02Translate expressions into backend SQL
  3. 03Defer execution with lazy evaluation
  4. 04Provide filtering, joins, and aggregations
  5. 05Support multiple expression types

Use cases

  1. 01Explore data locally with DuckDB
  2. 02Deploy analysis queries to PostgreSQL
  3. 03Build joins and aggregations in Python

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/brojonat/llmsrules --skill ibis-data

After installing, type/ibis-datain Claude Code to confirm it loaded.

Details

From the project README

Ibis Data Interface

Ibis provides a database-agnostic Python DataFrame API. Write queries once in Python; Ibis translates them to optimized SQL for the connected backend (DuckDB, PostgreSQL, SQLite, etc.).

Why Ibis

  • Portability: Develop with DuckDB, deploy against PostgreSQL -- change only the connection
  • Lazy evaluation: Operations build an expression tree; nothing executes until .execute()
  • Full SQL power: Window functions, CTEs, joins, aggregations -- all through Python
  • No ORM: You get SQL performance without SQL strings

Connecting

import ibis

# DuckDB (default for local/parquet work)
con = ibis.duckdb.connect()
con = ibis.duckdb.connect("my.duckdb")

# PostgreSQL
con = ibis.postgres.connect(host="localhost", database="mydb", user="user", password="pass")

# SQLite
con = ibis.sqlite.connect("my.sqlite")

# Read files directly
table = con.read_parquet("data.parquet")
table = con.read_csv("data.csv")

Core Operations

# Explore
table.schema()          # column names and types
table.head(10)          # preview rows
table.describe()        # summary statistics
table.count().execute() # row count

# Select and filter
selected = table.select("id", "amount", "date")
filtered = table.filter((table.amount > 100) & (table.date >= "2024-01-01"))
sorted_data = table.order_by(table.amount.desc())

# Transform
enriched = table.mutate(
    revenue=table.quantity * table.unit_price,
    year=table.date.year(),
    size=ibis.case()
        .when(table.amount < 100, "small")
        .when(table.amount < 1000, "medium")
        .else_("large")
        .end()
)

# Aggregate
summary = (
    table.group_by("category")
    .aggregate(
        total=table.amount.sum(),
        avg=table.amount.mean(),
        count=table.count()
    )
)

# Join
joined = (
    orders
    .join(customers, orders.customer_id == customers.id, how="left")
    .select(orders.order_id, orders.amount, customers.name)
)

# Window functions
ranked = table.mutate(
    rank=table.amount.rank().over(
        ibis.window(group_by="category", order_by=table.amount.desc())
    )
)

# Execute and export
df = summary.execute()              # -> pandas DataFrame
con.to_parquet(summary, "out.parquet")
df.to_csv("out.csv", index=False)

API Reference

APIWhat it covers
Table expressionsselect, filter, mutate, group_by, agg, join, order_by
SelectorsChoose columns by name, type, or regex
Generic expressions.cast(), .isnull(), .fillna(), case(), .ifelse()
Numeric expressionssum(), mean(), std(), rounding, logarithms
String expressionsSlicing, regex, case conversion, stripping
Temporal expressions.year(), .month(), interval arithmetic, formatting
Collection expressionsArray/map operations, unnesting
JSON expressionsPath-based extraction from JSON columns

Best Practices

  • Filter early: Reduce data volume before aggregations
  • Stay lazy: Chain operations before calling .execute()
  • Use selectors: Apply operations to multiple columns programmatically
  • Handle nulls: Check with .isnull() and handle with .fillna() explicitly
  • Check SQL: Use ibis.to_sql(expr) to inspect generated queries

Installation

uv add "ibis-framework[duckdb]"        # DuckDB backend
uv add "ibis-framework[postgres]"      # PostgreSQL backend

Comments

Markdown supported