Python Forum
I want to vectorize a really long for loop to improve performance
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I want to vectorize a really long for loop to improve performance
#2
My advice depends largely on how many times you plan to run this. If once, it will take you more time to learn and rewrite the code than it will to just let this run for the 33 minutes in the estimate you quote. However, if this is to be done multiple times I would use Pandas. Not a bad idea to learn Pandas anyway, lots of Youtubes and other sources on the net. Pandas is not only fast but also opens a range of functions to make things (relatively) easy.

Pandas supports an object called a Dataframe. Think of this as a spreadsheet or table where you can then reference entire columns by name. Won't eliminate the need for For loops but close.
Reply


Messages In This Thread
RE: I want to vectorize a really long for loop to improve performance - by jefsummers - Jul-18-2021, 11:13 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long long' MaJeFi 2 12,582 Mar-20-2019, 06:00 AM
Last Post: MaJeFi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020