Sample rows from pandas DataFrame

Post date: Jul 23, 2015 8:48:29 PM

See this link:

http://stackoverflow.com/questions/12190874/pandas-sampling-a-dataframe

In [117]: import pandas  In [118]: import random  In [119]: df = pandas.DataFrame(np.random.randn(100, 4), columns=list('ABCD'))  In [120]: rows = random.sample(df.index, 10)  In [121]: df_10 = df.ix[rows]  In [122]: df_90 = df.drop(rows)