Accelerate Pandas 20x using FireDucks

…by changing just one line of code.

Moazzam suleman
3 min readSep 10, 2024

Two of the biggest problems with Pandas is that:

  • It always adheres to a single-core computation on a CPU.
  • It creates bulky DataFrames.

Moreover, since Pandas follows an eager execution mode (every operation triggers immediate computation), it cannot prepare a smart execution plan that optimizes the entire sequence of operations.

FireDucks is a heavily optimized alternative to Pandas with exactly the same API as Pandas’ that addresses these limitations.

Let’s learn more about it today!

How to use it?

First, install the library:

FireDucks is currently available for Linux on the x86_64 architecture.

Next, there are three ways to use it:

  1. If you are using IPython or Jupyter Notebook, load the extension as follows:

2. Additionally, FireDucks also provides a pandas-like module (fireducks.pandas), which can be imported instead of using Pandas. Thus, to use FireDucks in an existing Pandas pipeline, replace the standard import statement with the one from FireDucks:

3. Lastly, if you have a Python script, executing it as shown below will automatically replace the Pandas import statement with FireDucks:

Done!

It’s that simple to use FireDucks.

The speedup is evident from the gif below from my personal experimentation:

I haven’t shown the full animation due to size limitations, but Pandas code ran in 12.3 seconds while the FireDucks code ran in 3.5 seconds, ~4x speedup:

Speedups typically vary from system to system since FireDucks is driven with multiple cores. The same code above, on a system with more CPU cores, will most likely result in more speedup. In my experimentation, I used the standard Google Colab runtime and FireDucks 1.0.3.

As per FireDucks’ official benchmarks, it can be ~20x faster than Pandas and ~2x faster than Polars, as shown below on several queries:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Moazzam suleman
Moazzam suleman

Written by Moazzam suleman

I'm an AI enthusiast with expertise in NLP, computer vision, and ML. I've published papers, won AI awards, and prioritize ethical AI.

No responses yet

Write a response