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
and at
working with scalar only, so very fast. Slower, more general functions are iloc
and loc
.
You can check docs:
Since indexing with [] must handle a lot of cases (single-label access, slicing, boolean indexing, etc.), it has a bit of overhead in order to figure out what you’re asking for. If you only want to access a scalar value, the fastest way is to use the at and iat methods, which are implemented on all of the data structures.
Similarly to loc, at provides label based scalar lookups, while, iat provides integer based lookups analogously to iloc.