👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
How to shuffle rows in a Pandas dataframe in Python?

In Python, to shuffle rows in a dataframe, use the .sample() method:

df.sample(frac=1)


If you wish to shuffle and reset the index, use:

df = df.sample(frac=1).reset_index(drop=True)

More