If I have a datafame with two groups, how can I select a random 50% of the rows associated with one group, and 100% of the rows associated with the other group? This is the code so far, which will give me 50% of both groups. Thanks in advance.
df1=df1.sample(n=len(df1))
grouped = df1.groupby(['group'], as_index=False)
newgroups=grouped.apply(lambda x: x.sample(frac=0.5) if 'group' == 1 else x.sample(frac=1.0))