Asked about Thinking in arrays
Why is vectorised NumPy faster than a Python loop?
An answer that works
The loop executes in the Python interpreter with per-element overhead, while the vectorised operation runs in compiled code over contiguous memory, often using multiple values per instruction. The difference is typically one to two orders of magnitude.
Reading an answer is not being able to give one. The section that teaches this is Thinking in arrays, 6 hours of NumPy & pandas.
Learn this properlyAlso asked about NumPy & pandas
What does SettingWithCopyWarning mean?How would you handle missing values?What is the difference between a view and a copy in NumPy?How do you reduce the memory a DataFrame uses?After a join, your total revenue doubled. What happened?A pandas job on a 20 GB CSV runs out of memory. What are your options?