Open sourceApache 2.0

ClickHouse pandas

Get governed ClickHouse metrics into pandas, by name

Notebooks are where numbers drift. hypequery lets analysts query the same measures and dimensions your product and dashboards use, so a DataFrame of “revenue by month” matches what customers see.

Works in

Jupyter, scripts, jobs

Output

pandas, Polars, Arrow

Types

From your definitions

Every notebook has its own revenue

Analysts copy a SQL query from a dashboard, tweak it, and the number in the deck no longer matches the product.

Joins and filters get re-derived

Each analysis rediscovers which status counts as completed, which table holds refunds, and how to bucket by week.

Customer data needs a deliberate scope

A notebook that forgets the tenant filter silently mixes customers. Cross-customer analysis should be explicit.

Notebook

Query the definitions, not the tables

Import the datasets your application defines, query measures by name with a time grain, and call to_pandas().

  • Measures, filters, and relationships come from reviewed code
  • Time grains like by="month" produce a timezone-aware period column
  • to_polars() and to_arrow() work the same way
  • The same query runs in a scheduled job without changes

notebook

Revenue by month into a DataFrame

analysis.ipynb

ClickHouseConnection.from_env() reads CLICKHOUSE_URL or the CLICKHOUSE_* variables.

Types and scope

Typed columns, from the definition

Each column’s type comes from the dataset, not from guessing at values: time buckets become datetimes in the query’s timezone, counts nullable integers, other measures floats. An empty result gets the same dtypes.

Pass decimals="decimal" to keep ClickHouse decimals exact. Integers beyond Int64 become unsigned or exact columns rather than overflowing.

Tenant-scoped datasets require a tenant. For internal analysis across every customer, pass all_tenants() explicitly so the intent is visible in the code.

notebook

Typed columns and cross-customer analysis

analysis.ipynb

Output shown from a sample orders table.

Where teams usually get stuck

Questions teams ask

ClickHouse to pandas DataFrame

Query measures through hypequery and call result.to_pandas() for typed columns.

Metrics layer for notebooks

Analysts and the product read the same definitions, so numbers match across decks and dashboards.

clickhouse-connect query_df

clickhouse-connect returns DataFrames for raw SQL. hypequery returns them for named measures, with validation and tenancy.

Polars or Arrow?

result.to_polars() and result.to_arrow() use the same column types. Install hypequery[polars] or hypequery[arrow].

Next step

Rebuild one notebook query on a dataset

Pick the query behind your most-shared chart, define it as a dataset, and compare the numbers.

Open source, and it runs in your own backend. Want it hosted?

Get early access to hypequery cloud.

Cloud hosts the same model you run in your backend, with a managed API and MCP server, versions, and rollback. We're letting teams in a few at a time. Join the waitlist and we'll reach out when your project can go live.

How do you want to build your analytics layer? (Optional)
What features do you most need? (Optional)

Pick as many as you like.

Only your email is required. All other questions are optional.