Don’t use loc/iloc with Loops In Python, Instead, Use This!

Run your loops at a 60X faster speed

Anmol Tomar
CodeX
Published in
3 min readJan 24, 2024

--

Pic Credit: Unsplash

Recently, I was experimenting with loops in Python and realized that using ‘iloc’/ ‘loc’ within the loops takes a lot of time to execute. The immediate next question was why is ‘loc’ taking too much time and what is the alternative to ‘loc’?

--

--

Anmol Tomar
CodeX
Writer for

Top AI writer | Data Science Manager | Mentor. Want to kick off your career in Data Science? Get in touch with me: https://www.analyticsshiksha.com/