janitor.shuffle¶
-
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()
- Parameters
df – A pandas DataFrame
random_state – (optional) A seed for the random number generator.
reset_index – (optional) Resets index to default integers
- Returns
A shuffled pandas DataFrame.