Skip to content

Instantly share code, notes, and snippets.

@ianmcook
Created January 24, 2023 18:01
Show Gist options
  • Select an option

  • Save ianmcook/f2bb40ab6e2c145b72f82e703b35b539 to your computer and use it in GitHub Desktop.

Select an option

Save ianmcook/f2bb40ab6e2c145b72f82e703b35b539 to your computer and use it in GitHub Desktop.
Ibis + DuckDB example
# 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
@ianmcook
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment