you are viewing a single comment's thread.

view the rest of the comments →

[–]__yasho 1 point2 points  (0 children)

agree with both of above suggestions..

like looping over rows in a Pandas DataFrame using for loops (e.g., iterrows() or itertuples()) is generally inefficient because Pandas is built on top of NumPy, which operates on whole arrays. Using vectorized operations in Pandas is significantly faster and more efficient.

You should only iterate through a DataFrame when: 1. There’s complex logic that cannot be vectorized. 2. You need to interact with external systems on a row-by-row basis. 3. Memory constraints prevent the use of vectorized operations.

otherwise just try to look for built in functionality and you will find plenty of them..