Join tables to combine data

Combine data from multiple tables using inner, left, and cross joins.

Core Operations · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

How it works

Use table1.join(table2, on=..., how=...) to combine tables based on matching columns.

What it covers

  • Inner join to match rows from both tables
  • Left join to keep all rows from the first table
  • Cross join for Cartesian product (all combinations)
  • Join with filtering, aggregation, and saving results
  • Paginate results with limit() and offset

What it uses

Install
terminal
pip install pixeltable
Pixeltable calls
pxt.create_table()insert()join()group_by()

A look at the code

query-join-tables.ipynb
# Create a customers table
customers = pxt.create_table(
'join_demo/customers',
{'customer_id': pxt.Int, 'name': pxt.String, 'email': pxt.String},
)
customers.insert(
[
{'customer_id': 1, 'name': 'Alice', 'email': '[email protected]'},
{'customer_id': 2, 'name': 'Bob', 'email': '[email protected]'},
{
'customer_id': 3,
'name': 'Charlie',
'email': '[email protected]',
},
]
)
customers.collect()

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103