Skip to content
Advertisement

Tag: performance

Reducing number of repeated queries in Django when creating new objects in a loop

I’m populating a database using Django from an Excel sheet. In the example below, the purchases list simulates the format of that sheet. My problem is that I’m repeatedly using Customer.objects.get to retrieve the same Customer object when creating new Purchase entries. This results in repeated database queries for the same information. I’ve tried using customers = Customer.objects.all() to read

How to improve performance of dataframe slices matching?

I need to improve the performance of the following dataframe slices matching. What I need to do is find the matching trips between 2 dataframes, according to the sequence column values with order conserved. My 2 dataframes: Expected output: This is the following code I’ m using: Despite working, this is very time costly and unefficient as my real dataframes

Improve the speed of code with if else statements

I am working on building a classs. But I realized that one part is extremly slow. I believe it is this part below, because when I call it, it takes couple of minutes which is too long. How can the speed of the function be improved? Not sure how the code can be improved to increase speed. There is a

Advertisement