I've recently noticed that a function where I iterate over a DataFrame
rows using .iloc
is very slow. I found out that there's a faster method called .iat
, that's said to be equivalent to .iloc
. I tried it and it cut the run time down by about 75%.
But I'm a little hesitant: why is there an "equivalent" method that's faster? There must be some difference between the inner workings of these two and a reason why they both exist and not just the faster one. I've tried looking everywhere but even the pandas documentation just states that
DataFrame.iat
Fast integer location scalar accessor.Similarly to iloc, iat provides integer based lookups. You can also set using these indexers.
And that doesn't help.
Are there limits to using .iat
? Why is faster; is it sloppier? Or do I just switch to using .iat
and happily forget .iloc
ever existed?