Q:

Grouping records and counting within groups

I have API data in JSON format.
{
    "players": [{
        "player_full_name": "ghny",

        "url": "...",

    }]
}

I need to group all records by division and get the count of players.
    players = json_response.get("players")

    # players = players("event")

    print(division)

A:

If your intention is to only count players, you can simply use collections.Counter with a generator expression.
from collections import Counter

... # process json to get an iterable named 'players'

Counter(player.get('division') for player in players)

If you need to keep the results for further processing, I would suggest that either you use itertools.groupby or look at something like the toolz library, which provides a friendlier api for groupby. 
If you plan on sticking with itertools.groupby, you will need to do something like:
player_division = lambda player: player.get('division') 
g = groupby(sorted(players, key=player_division), player_division)
players_by_division = {division: list(players) for division, players in g}

Note: the input to itertools.groupby has to be sorted in order to work properly

