Is there an equivalent of eachindex() for DataFrames?

To have high performance you need to use function barrier. Here is a most basic example:

function_barrier(vec) = ... your code iterating elements of a vector
map(function_barrier, eachcol(df))

The point is that in order to be efficient you must pass a column to a separate function. Then inside this function all will be fast.

The reason is that DataFrame object is not type stable, so for example even:

for col in eachcol(df)
    for v in col
        ... your code
    end
end

will be slow, because Julia does not know the element type of col at compilation time.

1 Like