FireDucks Documentation
repository·main·Indexed 21 days ago
https://github.com/fireducks-dev/fireducksFireDucks is a high-performance, compiler-accelerated dataframe library for Python designed as a fast, drop-in replacement for pandas. It features a JIT compiler for query planning and optimization, supporting lazy execution and method chaining to improve performance on large-scale data analysis. It can be integrated into existing workflows via an import hook or the `fireducks.pandas` module, and provides a `%%fireducks.profile` magic command for Jupyter notebooks.
What's inside FireDucks
- FireDucks is a high-performance, compiler-accelerated dataframe library for Python. It is designed for speed while maintaining compatibility with the pandas API. It is particularly effective at query planning and optimization for large-scale data analysis.
Use the FireDucks Import Hook
mainThe Import Hook allows you to use FireDucks without modifying your source code. It automatically replaces
import pandasstatements with FireDucks throughout your execution environment. This is ideal for existing programs or when using external libraries (likematplotlib) that might internally use pandas.For Python scripts: Run your script using the
-moption with thefireducks.pandasmodule.For IPython/Jupyter Notebooks: Use the
%load_extmagic command to activate the hook before importing pandas.# For scripts python3 -m fireducks.pandas your_script.py# For Jupyter/IPython %load_ext fireducks.pandas import pandas as pdProfile FireDucks performance with %%fireducks.profile
mainUse the
%%fireducks.profilemagic command in a Jupyter cell to profile the execution of your code. This is useful for observing the performance benefits of FireDucks' optimizations like Common Sub-expression Elimination, Dead Code Elimination, and Pushdown operations.%%fireducks.profile # Your pandas code here df.groupby("A").sum()Enable FireDucks in Jupyter Notebooks
mainTo use FireDucks as a drop-in replacement for pandas in a Jupyter environment, load the
fireducks.pandasextension. This allows you to use standardimport pandas as pdsyntax while benefiting from FireDucks' lazy execution and optimizations.%load_ext fireducks.pandas import numpy as np import pandas as pdUse Explicit Import for FireDucks
mainIf you prefer to be explicit, you can use the
fireducks.pandasmodule directly. To switch an existing pandas-based program to FireDucks, replace yourimport pandasstatement withimport fireducks.pandas.# Replace this: # import pandas as pd # With this: import fireducks.pandas as pdInstall FireDucks via pip
mainFireDucks is available for Linux (manylinux) on the x86_64 architecture. You can install it using
pip.Requirements:
- Python version: 3.9 to 3.13 (Note: Python 3.8 is no longer supported as of FireDucks 1.1.0 due to
pyarrow18.0.0 dependency).
If you use a Python version outside this range, you may encounter the error:
"No matching distribution found for fireducks".pip install fireducks- Python version: 3.9 to 3.13 (Note: Python 3.8 is no longer supported as of FireDucks 1.1.0 due to
Optimize queries using method chaining
mainTo achieve maximum performance benefits from the FireDucks JIT compiler, use method chaining for your queries.
When you write a query as a single chained expression, the compiler can optimize the entire data flow because it knows the intermediate results are not needed elsewhere. This allows it to reduce data loading overhead and parallelize the workload efficiently.
# Recommended: Method chaining for maximum JIT optimization fd.read_parquet("sample_data.parquet").pipe(lambda df: df[df["x"] == 1])["c"].sum()Avoid intermediate variables in notebooks for optimization
mainWhen working in a Jupyter notebook, avoid saving intermediate results in temporary variables.
If you assign an intermediate result to a variable (e.g.,
df = fd.read_parquet(...)), the compiler assumes that the variable might be used in a later cell. Consequently, it keeps all intermediate data alive, which prevents the JIT compiler from performing full data-flow optimizations.Note: This limitation is specific to notebooks. In standard Python scripts, the compiler can inspect the entire file to determine if a variable is used later, allowing for optimization even with intermediate variables.
# Inefficient in notebooks: Intermediate variables prevent optimization df = fd.read_parquet("sample_data.parquet") fdf = df[df["x"] == 1] fdf["c"].sum()Install FireDucks
mainYou can install FireDucks using pip. It is recommended to use the
-Uflag to ensure you are using the latest version.!pip install -q -U fireducksInstall FireDucks via pip
mainInstall the FireDucks library using pip. It is recommended to use the
-Uflag to ensure you are using the latest version.!pip install -q -U fireducks#!pip install -q -U fireducksInstall FireDucks, Polars, and Linetimer
mainTo use FireDucks alongside Polars and the Linetimer benchmarking tool, install them via pip:
!pip install -q -U fireducks polars linetimerInstall FireDucks and dependencies
mainTo use FireDucks, install it along with its required dependencies using
pip. This setup is often used in conjunction withpydanticandlinetimerfor configuration and performance measurement.!pip install -q -U fireducks pydantic pydantic_settings linetimer