Answers for "how to shuffle pandas dataframe"

8

pandas shuffle rows

df = df.sample(frac=1).reset_index(drop=True)
Posted by: Guest on November-26-2019
2

shuffle rows dataframe

df = df.sample(frac=1).reset_index(drop=True) #Use if you want to reset index order

df.sample(frac=1) # Use for no reset in index order
Posted by: Guest on July-17-2021
0

randomly shuffle pandas dataframe

  shuffled_train_df = train_df.reindex(np.random.permutation(train_df.index))
Posted by: Guest on July-09-2021

Code answers related to "how to shuffle pandas dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language