How to access pandas groupby dataframe by key
How do I access the corresponding groupby dataframe in a groupby object by the key? With the following groupby: rand = np.random.RandomState(1) df = pd.DataFrame({‘A’: [‘foo’, ‘bar’] * 3, ‘B’: rand.randn(6), ‘C’: rand.randint(0, 20, 6)}) gb = df.groupby([‘A’]) I can iterate through it to get the keys and groups: In [11]: for k, gp in … Read more