ibis
Expert guidance for Ibis, the Python dataframe library that provides a pandas-like API but generates SQL for execution on any backend — DuckDB, PostgreSQL, BigQuery, Snowflake, Spark, and more. Helps developers write analytics code once and run it anywhere without rewriting SQL for each database.
What this skill does
# Ibis — Portable Python Analytics
## Overview
Ibis, the Python dataframe library that provides a pandas-like API but generates SQL for execution on any backend — DuckDB, PostgreSQL, BigQuery, Snowflake, Spark, and more. Helps developers write analytics code once and run it anywhere without rewriting SQL for each database.
## Instructions
### Basic Usage
```python
# src/analytics.py — Portable analytics with Ibis
import ibis
from ibis import _ # Shorthand for column references
# Connect to a backend (DuckDB for local development)
con = ibis.duckdb.connect("analytics.duckdb")
# Or connect to production databases — same code, different backend
# con = ibis.postgres.connect(url="postgresql://...")
# con = ibis.bigquery.connect(project_id="my-project")
# con = ibis.snowflake.connect(...)
# Load data
orders = con.table("orders")
# Build a query — this is lazy (no execution until you call .execute())
monthly_revenue = (
orders
.filter(_.status == "completed")
.filter(_.created_at >= "2026-01-01")
.group_by(month=_.created_at.truncate("M"))
.agg(
revenue=_.amount.sum(),
order_count=_.count(),
unique_customers=_.customer_id.nunique(),
avg_order_value=_.amount.mean(),
)
.order_by(_.month)
)
# Execute and get a pandas DataFrame
df = monthly_revenue.execute()
print(df)
# Or see the generated SQL
print(ibis.to_sql(monthly_revenue))
```
### Complex Transformations
```python
# Window functions, joins, and case expressions
import ibis
from ibis import _
con = ibis.duckdb.connect("analytics.duckdb")
orders = con.table("orders")
customers = con.table("customers")
# Window functions — running totals and rankings
ranked = (
orders
.filter(_.status == "completed")
.group_by(_.customer_id)
.agg(
total_spent=_.amount.sum(),
order_count=_.count(),
first_order=_.created_at.min(),
last_order=_.created_at.max(),
)
.mutate(
# Rank customers by revenue
revenue_rank=ibis.rank().over(
order_by=ibis.desc(_.total_spent)
),
# Percentile
revenue_percentile=ibis.percent_rank().over(
order_by=_.total_spent
),
# Customer segment based on spending
segment=ibis.case()
.when(_.total_spent >= 1000, "whale")
.when(_.total_spent >= 100, "regular")
.else_("casual")
.end(),
)
)
# Joins
customer_analytics = (
ranked
.join(customers, _.customer_id == customers.id)
.select(
_.customer_id,
customers.name,
customers.email,
customers.plan,
_.total_spent,
_.order_count,
_.segment,
_.revenue_rank,
# Days since last order
days_inactive=(ibis.now() - _.last_order).cast("int32") // 86400,
)
)
# Cohort analysis
cohorts = (
orders
.filter(_.status == "completed")
.group_by(_.customer_id)
.mutate(
cohort_month=_.created_at.min().truncate("M"),
)
.mutate(
months_since=((_.created_at.truncate("M") - _.cohort_month)
.cast("int32") // (30 * 86400)),
)
.group_by(_.cohort_month, _.months_since)
.agg(
active_users=_.customer_id.nunique(),
revenue=_.amount.sum(),
)
)
```
### Backend Portability
```python
# The same analytics code runs on any backend
import ibis
def build_revenue_report(con: ibis.BaseBackend):
"""Build a revenue report — works on any Ibis backend.
Args:
con: Any Ibis connection (DuckDB, Postgres, BigQuery, etc.)
"""
orders = con.table("orders")
return (
orders
.filter(_.status == "completed")
.group_by(
month=_.created_at.truncate("M"),
category=_.category,
)
.agg(
revenue=_.amount.sum(),
orders=_.count(),
)
.order_by(_.month.desc())
)
# Development: DuckDB on local Parquet files
dev_con = ibis.duckdb.connect()
dev_con.read_parquet("data/orders.parquet", table_name="orders")
report = build_revenue_report(dev_con).execute()
# Production: BigQuery
prod_con = ibis.bigquery.connect(project_id="prod-project", dataset_id="analytics")
report = build_revenue_report(prod_con).execute()
# Testing: in-memory with DuckDB
test_con = ibis.duckdb.connect()
test_con.create_table("orders", test_data_df)
report = build_revenue_report(test_con).execute()
```
### UDFs and Custom Functions
```python
# Custom scalar and aggregate functions
import ibis
from ibis import udf
@udf.scalar.python
def normalize_email(email: str) -> str:
"""Normalize email addresses for deduplication."""
local, domain = email.lower().split("@")
# Remove dots and plus aliases from Gmail
if domain in ("gmail.com", "googlemail.com"):
local = local.split("+")[0].replace(".", "")
return f"{local}@{domain}"
# Use in queries
customers = con.table("customers")
deduped = (
customers
.mutate(clean_email=normalize_email(_.email))
.group_by(_.clean_email)
.agg(
count=_.count(),
first_seen=_.created_at.min(),
)
.filter(_.count > 1)
)
```
## Installation
```bash
# Core library
pip install ibis-framework
# With specific backends
pip install "ibis-framework[duckdb]"
pip install "ibis-framework[postgres]"
pip install "ibis-framework[bigquery]"
pip install "ibis-framework[snowflake]"
pip install "ibis-framework[pyspark]"
# Interactive mode (for notebooks)
ibis.options.interactive = True # Auto-execute and display results
```
## Examples
### Example 1: Migrating a pandas pipeline to run on BigQuery
**User request:**
```
I have a pandas script that calculates cohort retention from our events table. Rewrite it using Ibis so it runs on BigQuery instead of loading everything into memory.
```
The agent rewrites the pandas code using Ibis expressions (`ibis.bigquery.connect()`, `t.group_by()`, `_.mutate()`, window functions with `ibis.cumulative_window()`), keeping the same logic but generating SQL that executes on BigQuery. The script goes from loading 50M rows into memory to pushing all computation to the warehouse.
### Example 2: Building a portable analytics module with DuckDB for dev
**User request:**
```
Write an analytics module that computes daily active users and revenue per plan from Parquet files locally, but can switch to Snowflake in production.
```
The agent creates a module using `ibis.duckdb.connect()` for local development with Parquet files, writes composable Ibis expressions for DAU (`t.select('user_id', 'event_date').distinct().group_by('event_date').count()`) and revenue by plan, and adds a `get_connection()` function that switches to `ibis.snowflake.connect()` based on an environment variable — same analytics code, different backend.
## Guidelines
1. **Write once, run anywhere** — Define analytics logic with Ibis; swap backends by changing the connection, not the code
2. **Lazy by default** — Ibis expressions are lazy; they only execute when you call `.execute()` or `.to_pandas()`
3. **DuckDB for development** — Use DuckDB locally with Parquet files; switch to BigQuery/Snowflake for production
4. **Use `_` for readability** — `from ibis import _` gives you clean column references: `_.amount.sum()` vs `orders.amount.sum()`
5. **Generate SQL for debugging** — Use `ibis.to_sql(expr)` to see the SQL being generated; helps debug unexpected results
6. **Functions for reuse** — Wrap analytics logic in functions that take a connection; test with DuckDB, deploy on any backend
7. **Interactive mode in notebooks** — Set `ibis.options.interactive = True` for immediate result display during exploration
8. **Type your schemas** — Use `ibis.schema()` to define expected table schemas; catch type mismatches early
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.