How can I sample groups after a groupby in pandas? Say I want to get the first half of groups after groupby.
In [194]: df = pd.DataFrame({'name':['john', 'george', 'john','andrew','Daniel','george','andrew','Daniel'], 'hits':[12,34,13,23,53,47,20,48]})
In [196]: grouped = df.groupby('name')
There are 'john', 'george', 'andrew', 'daniel' 4 groups in grouped and I'm interested in getting 2 groups out of the 4. It doesn't matter which 2 groups it returns.
Thank you very much.