janitor.shuffle(df: pandas.core.frame.DataFrame, random_state=None, reset_index=True) → pandas.core.frame.DataFrame[source]

Shuffle the rows of the DataFrame.

This method does not mutate the original DataFrame.

Super-sugary syntax! Underneath the hood, we use df.sample(frac=1), with the option to set the random state.

Example usage:

df = pd.DataFrame(...).shuffle()
  • df – A pandas DataFrame

  • random_state – (optional) A seed for the random number generator.

  • reset_index – (optional) Resets index to default integers


A shuffled pandas DataFrame.