How to make Pandas extremely fast without changing any code.
Key Takeaways
Optimizes Pandas performance without changing code using advanced techniques
Full Transcript
let me show you how to make pandas many many times faster without changing your code this is probably going to be one of the best things that you learn today like if you are in the python World obviously you know pandas is probably the most popular library to manipulate to process data so I have here a quick example where I'm just going to load the data set is a large data set and we're going to run some queries and we are going to measure the performance of pandas on this data set so I'm going to start here by just importing pandas and as you can see here I'm printing out the name of the library that I'm currently using so that's pandas this is going to download the data set and the data set is the New York City parking data set from 2022 is parking violations it's a pretty big data set so there like I think it's like 1.5 million rows that we have in here so this section is just going to read this parquette file this is the name of the file and we're only interested in loading these five columns here in memory and then I'm going to print the first few rows from that data set and notice how I'm timing every single operation here like as we go forward I'm going to keep grabbing and recording how long it takes every one of these operations I'm going to run this it's going to take a couple seconds so here you get the first five rows uh printed out and I stored how long it took to do that operation in this variable here that we will later use okay so let's do now let's run a few queries this first query here will return which park in violation is the most commonly committed by vehicles from various US states so let me run this and we get all right so here are the five first elements here so you get the violation the description Etc uh the second query uh and by the way again I just timed that query and I stored it in query one then the second query will return which vehicle body types are the most frequently involved in parking violations so let's run that turns out that Suburbans are the first one followed by four doors SED Dan so who would have thought and the final query is how do parking violations vary across days of the weeks this is probably the most complex query the query that's going to take the longest here's the query here I'm printing the again the five the top five rows and then I'm timing that query uh so here we get Sundays and Saturdays and Mondays Etc so the final sale of this notebook here just takes all of these values the time it took to run every single operation and it sums them so we get how many seconds total uh it took pandas to do this and again this is just a very simple example you can think of like if you have an application that's using pandas in a more involved way with more data obviously you you can take an idea of how long that's going to take so the total time here was 12.54 seconds so I'm going to write down down that down here just so we remember that was 12.54 seconds and now comes the trick okay so I'm going to be using fire dots so fire dots is here in GitHub I'm going to leave a link to the repo somewhere here far dock is going to accelerate our code without having to change anything that's the important thing so I'm going to add here a new Cale put it at the top and let's install baru so that's going to be quiet uninstall if it already exists baru sorry I made a mistake here so I'm going to install the paru library and then I can replace this line so instead of importing pandas I'm going to import from fir do. pandas aspd and I'm just going to commend out this one here I'm going to run now so now every time I use PD I'm actually using the panda implementation of fire dots which they share the same interface so nothing in my code has to change so let's rerun everything here just going to go through all of it so you see what the performance uh optimization was by run this that took 2.81 seconds so 2.81 if I make that division that's 4.5 times faster without changing anything else literally a single line I was able to optimize my code 4.5 times make it 4. times five uh five faster this is a no-brainer if you have an application if you're using pandas check out firo again this is a there is a a GitHub repo here explains everything that you need to know they have more examples here they have compatibility charts Etc uh it's not only faster than pandas but it's even faster than polers which is an alternative to pandas and the good news with fire dos is that you don't have to change anything their website says that it could be up to 48 times faster than pandas I think this is an no-brainer I hope you enjoy it and I'll see you in the next one bye-bye
Original Description
I teach a live, interactive program that'll help you build production-ready Machine Learning systems from the ground up. Check it out here:
https://www.ml.school
To keep up with my content:
• Twitter/X: https://www.twitter.com/svpino
• LinkedIn: https://www.linkedin.com/in/svpino
🔔 Subscribe for more stories: https://www.youtube.com/@underfitted?sub_confirmation=1
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Underfitted · Underfitted · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Test-Time Augmentation In Machine Learning.
Underfitted
Don't Replace Missing Values In Your Dataset.
Underfitted
Introduction to Adversarial Validation In Machine Learning.
Underfitted
Introduction To Autoencoders In Machine Learning.
Underfitted
Active Learning. The Secret of Training Models Without Labels.
Underfitted
Early Stopping. The Most Popular Regularization Technique In Machine Learning.
Underfitted
The Confusion Matrix in Machine Learning
Underfitted
3 Tips to Build a Career in Machine Learning (Unconventional Advice)
Underfitted
I can predict cars CRASHING. And it's 99% accurate!
Underfitted
A Critical Skill People Learn Too LATE: Learning Curves In Machine Learning.
Underfitted
The BEST Machine Learning Interview Strategy.
Underfitted
OpenAI’s Whisper is AMAZING!
Underfitted
5 Lessons You’re NOT Taught in School
Underfitted
TensorFlow On Apple Silicon. Step-by-Step Instructions
Underfitted
Generating Images From Text. Stable Diffusion, Explained
Underfitted
The Wrong Batch Size Will Ruin Your Model
Underfitted
8 Mistakes Holding Your Career Back | Machine Learning
Underfitted
AI Just Solved a 53-Year-Old Problem! | AlphaTensor, Explained
Underfitted
Bias and Variance, Simplified
Underfitted
Should You Stop Splitting Your Data Like This?
Underfitted
The Function That Changed Everything
Underfitted
This Model Caused A Nuclear Disaster
Underfitted
Will Your Code Write Itself?
Underfitted
The Simplest Encoding You’ve Never Heard Of
Underfitted
Superhuman AI Cracked An Impossible Game! | DeepNash, Explained
Underfitted
Can you become a Data Scientist without a Ph.D?
Underfitted
How to 10x your productivity with ChatGPT?
Underfitted
Cheating the Prisoner's Dilemma
Underfitted
We integrated OpenAI's Whisper with Spot
Underfitted
The Machine Learning School program
Underfitted
We integrated ChatGPT with our robots
Underfitted
Solving complex tasks using a Large Language Model (LLM)
Underfitted
5 problems when using a Large Language Model
Underfitted
We just discovered faster sorting algorithms!
Underfitted
The 3 most important updates to OpenAI's API.
Underfitted
People are divided! Does GPT-4 understand what it says?
Underfitted
How much should you charge hourly as a Machine Learning freelancer?
Underfitted
Building a RAG application from scratch using Python, LangChain, and the OpenAI API
Underfitted
Building a RAG application using open-source models (Asking questions from a PDF using Llama2)
Underfitted
How to evaluate an LLM-powered RAG application automatically.
Underfitted
Step by step no-code RAG application using Langflow.
Underfitted
I built a simple game using Langchain. Here is a step by step tutorial.
Underfitted
I used the first AI Software Engineer for a week. This is happening.
Underfitted
I deployed a recommendation model. Testing Models In Production using Interleaving Experiments.
Underfitted
How to run PyTorch, TensorFlow, and JAX on your Mac (Apple Silicon)
Underfitted
How to train a model to generate image embeddings from scratch
Underfitted
Building an AI assistant that listens and sees the world (Step by step tutorial)
Underfitted
Why are vector databases so FAST?
Underfitted
A Machine Learning roadmap (the one I recommend to my students)
Underfitted
How to build a real-time AI assistant (with voice and vision)
Underfitted
An introduction to Mojo (for Python developers)
Underfitted
How does Lexical Scoping in Mojo 🔥 works (under 3 minutes)
Underfitted
Building a CI workflow for those who hate it (using GitHub Actions)
Underfitted
How to run Python Code in Mojo 🔥
Underfitted
AI will not take your job. Here is what I think will happen instead.
Underfitted
How to fine-tune a model using LoRA (step by step)
Underfitted
Late initialization in Mojo🔥 (Python doesn't support this)
Underfitted
The $1,000,000 problem AI can't solve
Underfitted
A gentle introduction to RAG (using open-source models)
Underfitted
Automating feedback using ChatGPT and Zapier
Underfitted
More on: Python for Data
View skill →Related Reads
📰
📰
📰
📰
Decoding the Link Between Pretraining and Reinforcement Learning
Dev.to · Pneumetron
Learning the Loop — #101 | What Is Machine Learning, Really?
Medium · AI
Learning the Loop — #101 | What Is Machine Learning, Really?
Medium · Deep Learning
The model benchmark is not your production benchmark
Dev.to · hefty
🎓
Tutor Explanation
DeepCamp AI