from python_lib_util import csvtools as c from operator import itemgetter import collections # STEP ONE: Read in needed data as a list of dicts data = c.read_as_dict('raw-csvs/2015-combined.csv') issuers_by_county = list() for row in data: att = dict() att ['i'] = row['Issuer Name'] att['s'] = row['State '] att['c'] = row['County'] # and if att['c'] == 'King And Queen': att['c'] = 'King and Queen' if att['c'] == 'Lake And Peninsula': att['c'] = 'Lake and Peninsula' if att['c'] == 'Lewis And Clark': att['c'] = 'Lewis and Clark' # census areas if att['c'] == 'Aleutians West': att['c'] = 'Aleutians West Census' if att['c'] == 'Dillingham': att['c'] = 'Dillingham Census' if att['c'] == 'Wade Hampton': att['c'] = 'Wade Hampton Census' if att['c'] == 'Bethel':
from python_lib_util import csvtools as c from operator import itemgetter import collections # STEP ONE: Read in needed data as a list of dicts data = c.read_as_dict('raw-csvs/2014-combined.csv') issuers_by_county = list() for row in data: att = dict() att['i'] = row['Issuer Name'] att['s'] = row['State'] att['c'] = row['County'].title() # and if att['c'] == 'King And Queen': att['c'] = 'King and Queen' if att['c'] == 'Lake And Peninsula': att['c'] = 'Lake and Peninsula' if att['c'] == 'Lewis And Clark': att['c'] = 'Lewis and Clark' # census areas if att['c'] == 'Aleutians West': att['c'] = 'Aleutians West Census' if att['c'] == 'Dillingham': att['c'] = 'Dillingham Census' if att['c'] == 'Wade Hampton': att['c'] = 'Wade Hampton Census' if att['c'] == 'Bethel': att['c'] = 'Bethel Census'
from python_lib_util import csvtools as c import collections from itertools import izip_longest, ifilter # STEP ONE: Read in needed data as a list of dicts data = c.read_as_dict('fips-join/2017-joined.csv') # list of dicts, group by fips id data_grp = collections.defaultdict(list) for row in data: data_grp[row['f']].append(row['i']) # get count of issuers by fips code issuers_by_county = list() for k, v in data_grp.items(): att = dict() # all issuers in a county att['ict'] = len(v) counter = collections.Counter(v) # convert counter object to dict counter_dict = dict(counter.items()) # split dict by key into a list of dicts chunks = [counter_dict.iteritems()] split = (dict(ifilter(None, v)) for v in izip_longest(*chunks)) split_list = list(split) # sort our list of dicts sorted_split = sorted(split_list) # split up our dicts into one dict per county for row in sorted_split:
from python_lib_util import csvtools as c # STEP ONE: Generate a list of fips codes, by combining stfips and ctyfips. # Also, include full county name + name w/o county + state in new lists data = c.read_as_dict('fips-join/fips.csv') aca_2014 = c.read_as_dict('filtered-csvs/2014-issuers-filtered.csv') aca_2015 = c.read_as_dict('filtered-csvs/2015-issuers-filtered.csv') aca_2016 = c.read_as_dict('filtered-csvs/2016-issuers-filtered.csv') aca_2017 = c.read_as_dict('filtered-csvs/2017-issuers-filtered.csv') fips_codes = list() # what about OBrien for row in data: att = dict() att['f'] = row['stfips'] + row['ctyfips'] att['c'] = row['name'] att['s'] = row['state'] c0 = row['name'].split(' ') # range is from 2 - 5 if 'city' == c0[1]: att['c0'] = " ".join(c0[:2]) if 'city' != c0[1] and len(c0) == 2: att['c0'] = c0[0] if len(c0) == 3 and 'city' == c0[2]: att['c0'] = " ".join(c0) if len(c0) == 3 and 'city' != c0[2]: att['c0'] = " ".join(c0[:2]) if len(c0) == 4: att['c0'] = " ".join(c0[:3]) # print att['c0'] if len(c0) == 5:
from python_lib_util import csvtools as c from operator import itemgetter import collections # STEP ONE: Read in needed data as a list of dicts data = c.read_as_dict('raw-csvs/2016.csv') issuers_by_county = list() for row in data: att = dict() att ['i'] = row['Issuer Name'] att['s'] = row['State Code'] att['c'] = row['County Name'] # and if att['c'] == 'King And Queen': att['c'] = 'King and Queen' if att['c'] == 'Lake And Peninsula': att['c'] = 'Lake and Peninsula' if att['c'] == 'Lewis And Clark': att['c'] = 'Lewis and Clark' # census areas if att['c'] == 'Aleutians West': att['c'] = 'Aleutians West Census' if att['c'] == 'Dillingham': att['c'] = 'Dillingham Census' if att['c'] == 'Wade Hampton': att['c'] = 'Wade Hampton Census' if att['c'] == 'Bethel':
from python_lib_util import csvtools as c from operator import itemgetter import collections # STEP ONE: Read in needed data as a list of dicts data = c.read_as_dict('filtered-csvs/2016-issuers-filtered.csv') issuers_2017 = list() # STEP TWO: Remove issuers reported as leaving in 2017 for row in data: # AL changes if row['s'] == 'AL' and row['i'] == 'Humana Insurance Company': continue if row['s'] == 'AL' and row['i'] == 'UnitedHealthcare of Alabama, Inc.': continue # AK changes if row['s'] == 'AK' and row['i'] == 'Moda Health Plan, Inc.': continue # AZ changes if row['s'] == 'AZ' and row['i'] == 'All Savers Insurance Company': continue if row['s'] == 'AZ' and row['i'] == 'Health Net of Arizona, Inc.': continue if row['s'] == 'AZ' and row['c'] == 'Maricopa' and row['i'] == 'Blue Cross and Blue Shield of Arizona, Inc.': continue if row['s'] == 'AZ' and row['c'] == 'Pinal' and row['i'] == 'Blue Cross and Blue Shield of Arizona, Inc.': continue # AR changes if row['s'] == 'AR' and row['i'] == 'UnitedHealthcare of Arkansas, Inc.': continue
from python_lib_util import csvtools as c from operator import itemgetter import collections # STEP ONE: Read in needed data as a list of dicts data = c.read_as_dict('raw-csvs/2016.csv') issuers_by_county = list() for row in data: att = dict() att['i'] = row['Issuer Name'] att['s'] = row['State Code'] att['c'] = row['County Name'] # and if att['c'] == 'King And Queen': att['c'] = 'King and Queen' if att['c'] == 'Lake And Peninsula': att['c'] = 'Lake and Peninsula' if att['c'] == 'Lewis And Clark': att['c'] = 'Lewis and Clark' # census areas if att['c'] == 'Aleutians West': att['c'] = 'Aleutians West Census' if att['c'] == 'Dillingham': att['c'] = 'Dillingham Census' if att['c'] == 'Wade Hampton': att['c'] = 'Wade Hampton Census' if att['c'] == 'Bethel': att['c'] = 'Bethel Census'