How to sample rows from a dataframe?

You can use StatsBase.sample to sample without replacement, and (optionally) keep the order:

using StatsBase, DataFrames
myDF = DataFrame(A = 1:10, B = 21:30)
myDF[sample(axes(myDF, 1), 3; replace = false, ordered = true), :]
5 Likes