size = 2 # sample size replace = True # with replacement fn = lambda obj: obj.loc[np.random.choice(obj.index, size, replace),:] df.groupby('Group_Id', as_index=False).apply(fn)