Python Answers

How to shuffle python Pandas DataFrame rows?

Spread the love

To shuffle python Pandas DataFrame rows, we call the data frame sample method.

For instance, we write


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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.