Skip to content

Instantly share code, notes, and snippets.

@ansrivas
Last active December 1, 2015 19:25
Show Gist options
  • Select an option

  • Save ansrivas/64f2b01386c59d7f5d30 to your computer and use it in GitHub Desktop.

Select an option

Save ansrivas/64f2b01386c59d7f5d30 to your computer and use it in GitHub Desktop.
#use this to shuffle all the rows of pandas dataframe ( useful for some training algorithms )
import numpy as np
import pandas as pd
A = np.array([1, 2, 3])
B = np.array(['A', 'B', 'C'])
df = pd.DataFrame({'col1':A, 'col2':B})
print df.head()
print df.iloc[np.random.permutation(len(df))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment