Created
January 24, 2023 18:01
-
-
Save ianmcook/f2bb40ab6e2c145b72f82e703b35b539 to your computer and use it in GitHub Desktop.
Ibis + DuckDB example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pip install 'ibis-framework[duckdb]' | |
| import pandas as pd | |
| import ibis | |
| from ibis import _ | |
| # create a pandas DataFrame and write it to a Parquet file | |
| df = pd.DataFrame(data={'repo': ['pandas', 'duckdb', 'ibis'], | |
| 'stars': [36622, 8074, 2336]}) | |
| df.to_parquet('repo_stars.parquet') | |
| # use Ibis and DuckDB to query the Parquet file | |
| t = ibis.read_parquet('repo_stars.parquet') | |
| (t | |
| .filter(_.repo != 'pandas') | |
| .order_by(_.stars) | |
| .execute() | |
| ) | |
| # repo stars | |
| # 0 ibis 2336 | |
| # 1 duckdb 8074 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As shown at https://twitter.com/ianmcook/status/1617933102931939329