We can easily shuffle our pandas data frame by taking a sample of fraction=1
, where in essence we get a sample of all rows without replacement. The code:
import pandas as pd # assume that the df is your Data Frame df.sample(frac=1).reset_index(drop=True)