Ibis¶
Expressive analytics in Python at any scale.¶
Installation¶
pip install ibis-framework
conda install -c conda-forge ibis-framework
mamba install -c conda-forge ibis-framework
Try it out!
python -c 'import ibis; print(ibis.__version__)'
Features¶
SQL Coverage¶
Anything you can write in a SELECT
statement you can write in Ibis.¶
Coming from SQL?
Check out Ibis for SQL Programmers
Abstract Over SQL Dialects¶
No more rewrites when scaling up or down.¶
con = ibis.sqlite.connect("my_sqlite.db")
con = ibis.postgres.connect(user="me", host="my_computer", port=9090)
con = ibis.bigquery.connect(project_id="my_project_id", dataset_id="my_dataset_id")
t = con.table("t")
t.group_by("y").mutate(z=t.x.avg())
Ecosystem¶
Ibis builds on top of and works with existing Python tools.¶
t.semi_join(s, t.x == t.y).select([lambda t: t.a.exp().name("d")]).head(2)
df = expr.execute() # a pandas DataFrame!
Example¶
Let's compute the number of citizens per squared kilometer in Asia:
>>> import ibis
>>> db = ibis.sqlite.connect("geography.db")
>>> countries = db.table("countries")
>>> asian_countries = countries.filter(countries.continent == "AS")
>>> density_in_asia = asian_countries.population.sum() / asian_countries.area_km2.sum()
>>> density_in_asia.execute()
130.7019141926602
Learn more!
Learn more about Ibis in our tutorial.
Comparison to other tools¶
Coming from SQL?
Check out Ibis for SQL Programmers!
Ibis gives you the benefit of a programming language. You don't need to sacrifice maintainability to get to those insights!
docs/example.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
docs/example.sql | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Ibis aims to be more concise and composable than SQLAlchemy when writing interactive analytics code.
Ibis 's SQLAlchemy
Ibis generates SQLAlchemy expressions for some of our backends including the PostgreSQL and SQLite backends!
docs/example.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
docs/sqlalchemy_example.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
What's Next?¶
Need a specific backend?
Take a look at the backends documentation!
Interested in contributing?
Get started by setting up a development environment!
Last update:
April 4, 2022