Interview practice question
Slow Python loop over arrays
Machine Learning · ML Frameworks · Beginner
Your feature calculation loops over a million rows in Python and takes 20 minutes. How do you speed it up?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Vectorize with NumPy/pandas operations.
- Use built-in functions (np.where, cumsum, groupby).
- Numba JIT for complex loops.
- Profile first.
- Polars for heavier transformations.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.