3 ms·
DuckDB understands Pandas and Polars dataframes so you can move back and forth seamlessly between them in-memory (with Polars, it's nearly zero-copy via an in-m
by wenc 2y ago
DuckDB understands Pandas and Polars dataframes so you can move back and forth seamlessly between them in-memory (with Polars, it's nearly zero-copy via an in-memory data structure).
df = pd.DataFrame({"a": [1,2,3], "b": [4,5,6]}) # New Pandas dataframe
df2 = duckdb.query("select 2*a as c, b from df") # DuckDB
df3 = df2.df() # materialize as Pandas, .pl() for Polars
ml_df = ML.func(df3) # pass dataframe into ML function
df4 = duckdb.query("select count(distinct x) from ml_df")