How would I divide each row of a Julia dataframe by that rows maximum and return a new dataframe

I got one more: although it’s getting a bit ridiculous syntax wise :slight_smile:

function fasterbaz3!(m)
    nrows, ncols = size(m)

    maximums = m[:, 1] # copying the first col saves one col in the first iteration haha

    # iterate down the rows first which matches julia's memory layout
    @inbounds for j in 2:ncols, i in 1:nrows
        maximums[i] = max(maximums[i], m[i, j])
    end

    @inbounds for j in 1:ncols, i in 1:nrows
        m[i, j] /= maximums[i]
    end
end
@btime fasterbaz3!($m);
  113.390 μs (1 allocation: 7.94 KiB)
1 Like