Я решил проблему, благодаря Эдоардо Герриеро и небольшим изменениям:
groups = [1,2,3,4,5,6,7,8]
sample_sizes = [1, 30, 70, 1, 5, 40, 20, 70]
samples = []
for group, sample_size in zip(groups, sample_sizes):
samples.append(allthedata.groupby("groupingvar").get_group(group).sample(sample_size, random_state=4465))
# concatenate all samples into unique data frame
finaldf = pd.concat(samples)