def school_types_bar_chart():
    schools_2016 = get_schools('urn/2016.urns.list', 2016)
    schools_2015 = get_schools('urn/2015.urns.list', 2015)

    y_data = { 'SR2015': [], 'SR2016': [] }
    x_categories = []
    est_types = {}

    def _update_types(schools_dict):
        for s in schools_dict:
            est_type = s.data['typeOfEstablishment']['label']
            year = s.data['comp']
            try:
                est_types[est_type][year] += 1
            except KeyError:
                est_types[est_type] = { 2015: 0, 2016: 0 }
                est_types[est_type][year] += 1

    _update_types(schools_2015)
    _update_types(schools_2016)

    for est_type, yc in est_types.iteritems():
        y_data['SR2015'].append(yc[2015])
        y_data['SR2016'].append(yc[2016])
        x_categories.append(est_type)

    output_file('visuals/establisment_types.html')
    bar = Bar(y_data, cat=x_categories, title='Establishment Types and count', xlabel='Type of Establishment', ylabel='Count', width=1000, height=600, legend=True)

    show(bar)
Пример #2
0
def locations_bar_chart():
    schools_2016 = get_schools("urn/2016.urns.list", 2016)
    schools_2015 = get_schools("urn/2015.urns.list", 2015)

    y_data = {"SR2015": [], "SR2016": []}
    x_categories = []
    locations = {}

    def _update_locations(schools_dict):
        for s in schools_dict:
            addr = s.data["address"]
            try:
                town = addr["town"]
            except KeyError:
                town = addr["address3"]
            year = s.data["comp"]
            try:
                locations[town][year] += 1
            except KeyError:
                locations[town] = {2015: 0, 2016: 0}
                locations[town][year] += 1

    _update_locations(schools_2015)
    _update_locations(schools_2016)

    for loc, yc in locations.iteritems():
        y_data["SR2015"].append(yc[2015])
        y_data["SR2016"].append(yc[2016])
        x_categories.append(loc)

    output_file("visuals/locations_count.html")
    bar = Bar(
        y_data,
        cat=x_categories,
        title="School count and locations",
        xlabel="Locations",
        ylabel="Count",
        width=1000,
        height=600,
        legend=True,
    )

    show(bar)
Пример #3
0
def get_data(years):
    schools = get_schools(['raw_data/2015-teams.yaml'], [2015])

    d = OrderedDict()
    d['rookie'] = []
    d['veteran'] = []

    for s in schools:
        for year in years:
            rookie = s.data[year]['rookie']
            league_position = s.data[year]['league']

            if rookie:
                d['rookie'].append((year, league_position))
            else:
                d['veteran'].append((year, league_position))
    return d