To shuffle python Pandas DataFrame rows, we call the data frame sample
method.
For instance, we write
df.sample(frac=1)
to call sample
on the df
data frame.
The frac
keyword argument specifies the fraction of rows to return in the random sample, so frac=1
means to return all rows in random order.