def SampleRows(df, nrows, replace=False):
 indices = np.random.choice(df.index, nrows, replace=replace)
 sample = df.loc[indices]
 return sample

def SampleRows ( df , nrows , replace = False ) : indices = np . random . choice ( df . index , nrows , replace = replace ) sample = df . loc [ indices ] return sample
choose a sample of rows from a dataframe .