SQL on Pandas
Pandas DataFrames stored in local variables can be queried as if they are regular tables within DuckDB.
import duckdbimport pandas
# Create a Pandas dataframemy_df = pandas.DataFrame.from_dict({'a': [42]})
# query the Pandas DataFrame "my_df"# Note: duckdb.sql connects to the default in-memory database connectionresults = duckdb.sql("SELECT * FROM my_df").df()The seamless integration of Pandas DataFrames into DuckDB SQL queries is allowed by replacement scans, which replace instances of accessing the my_df table (which does not exist in DuckDB) with a table function that reads the my_df dataframe.