I have a vector of row numbers and I want to use it to permute a DataFrame’s rows. Here is an MVE
using StatsBase
df = DataFrame(a = rand(1_000_000))
r=sample(1:size(df,1), size(df,1), replace=false)
@time df = df[r,:]
I think the above creates a DataFrame and then assigns it to df
. Is there a way to re-assign the rows in place so minimal extra memory is allocated?