Integrating Polars with Opteryx
This short guide demonstrates how to integrate Polars and Opteryx, showing you how to query a Polars dataframe with Opteryx and how to return Polars dataframe from Opteryx.
Installation
Install Opteryx and Polars.
Polars to Opteryx
Opteryx can natively query Polars DataFrames by registering the DataFrame as a data source.
import opteryx
import polars
# Create the DataFrame
data = {
"Name": ["Huey", "Dewey", "Louie"],
"Age": [12, 12, 12],
"Favorite Color": ["Red", "Blue", "Green"],
}
df = polars.DataFrame(data)
# Register as a data source
opteryx.register_df("nephews", df)
results = opteryx.query("SELECT * FROM nephews")
Opteryx to Polars
Opteryx can output results as Polars DataFrames using the .polars() result-conversion method.
Related Guides
- Pandas Integration - Use Pandas for data manipulation
- Using Opteryx with Jupyter - Interactive data analysis in notebooks
- Connect to BigQuery - Join DataFrames with BigQuery tables
- Query AWS S3 - Query cloud storage alongside DataFrames