how to randomize the order of a dataframe in python code example Example: python randomize a dataframe pandas df = df.sample(frac=1).reset_index(drop=True)