Skip to content

Instantly share code, notes, and snippets.

@tdsmith
Created September 24, 2014 01:10
Show Gist options
  • Save tdsmith/cb762f3158eb60927759 to your computer and use it in GitHub Desktop.
Save tdsmith/cb762f3158eb60927759 to your computer and use it in GitHub Desktop.
In [1]: import pandas as pd
In [2]: df = pd.DataFrame({'foo': ['a', 'a', 'b', 'b'], 'bar': [1,2,3,4]})
In [3]: g = df.groupby('foo')
In [5]: for group in g:
...: print(group)
...:
('a', bar foo
0 1 a
1 2 a)
('b', bar foo
2 3 b
3 4 b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment