I know this must have been answered some where but I just could not find it.
Problem: Sample each group after groupby operation.
import pandas as pd
df = pd.DataFrame({'a': [1,2,3,4,5,6,7],
'b': [1,1,1,0,0,0,0]})
grouped = df.groupby('b')
# now sample from each group, e.g., I want 30% of each group