Skip to content

Instantly share code, notes, and snippets.

@GeorgeSeif
Last active October 11, 2019 11:19
Show Gist options
  • Save GeorgeSeif/dcb24b839c428bb88791c3b4b15ea74d to your computer and use it in GitHub Desktop.
Save GeorgeSeif/dcb24b839c428bb88791c3b4b15ea74d to your computer and use it in GitHub Desktop.
groups_df = df.groupby('Player')
for player, group in groups_df:
print("----- {} -----".format(player))
print(group)
print("")
### This prints out the following
"""
----- Batman -----
Player Year Points
1 Batman 2000 43
3 Batman 2001 65
6 Batman 2002 23
9 Batman 2004 76
----- Black Widow -----
Player Year Points
8 Black Widow 2003 89
----- Superman -----
Player Year Points
0 Superman 2000 23
5 Superman 2002 34
11 Superman 2005 87
----- Thanos -----
Player Year Points
2 Thanos 2000 45
4 Thanos 2001 76
7 Thanos 2002 78
10 Thanos 2004 92
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment