def parse_5_x(self, row): #self.inputs will be used in the aggregation functions #note: sequence number did not exist prior to 2012 and HUD median income became FFIEC median income in 2012 #instantiate classes to set loan variables MSA_index = MSA_info() #contains functions for census tract characteristics demo=demographics() #contains functions for borrower characteristics app_races = [row['applicantrace1'], row['applicantrace2'], row['applicantrace3'],row['applicantrace4'],row['applicantrace5']] co_app_races = [row['coapplicantrace1'], row['coapplicantrace2'], row['coapplicantrace3'],row['coapplicantrace4'],row['coapplicantrace5']] a_race = demo.make_race_list(app_races) #put applicant race codes in a list 0-5, 0 is blank field co_race = demo.make_race_list(co_app_races) #put co-applicant race codes in a list 0-5, 0 is blank field #add data elements to dictionary self.inputs['a_race'] = a_race self.inputs['co_race'] = co_race self.inputs['a ethn'] = row['applicantethnicity'] #ethnicity of the applicant self.inputs['co ethn'] = row['coapplicantethnicity'] #ethnicity of the co-applicant self.inputs['income'] = row['applicantincome'] #relied upon income rounded to the nearest thousand self.inputs['loan value'] = float(row['loanamount']) #loan value rounded to the nearest thousand self.inputs['year'] = row['asofdate'] #year or application or origination self.inputs['state code'] = row['statecode'] #two digit state code self.inputs['state name'] = row['statename'] #two character state abbreviation self.inputs['action taken'] = int(row['actiontype']) #disposition of the loan application self.inputs['MSA median income'] = row['ffiec_median_family_income'] #median income for the tract/msa self.inputs['sequence'] = row['sequencenumber'] #the sequence number of the loan, used for checking errors self.inputs['income bracket'] = MSA_index.app_income_to_MSA(self.inputs) #sets the applicant income as an index by an applicant's income as a percent of MSA median self.inputs['app non white flag'] = demo.set_non_white(a_race) #flags the applicant as non-white if true, used in setting minority status and race self.inputs['co non white flag'] = demo.set_non_white(co_race) #flags the co applicant as non-white if true, used in setting minority status and race self.inputs['minority count'] = demo.minority_count(a_race) #determines if the number of minority races claimed by the applicant is 2 or greater self.inputs['joint status'] = demo.set_joint(self.inputs) #requires non white status flags be set prior to running set_joint self.inputs['race'] = demo.set_race(self.inputs, a_race) #requires joint status be set prior to running set_race self.inputs['ethnicity'] = demo.set_ethnicity(self.inputs) #requires ethnicity be parsed prior to running set_ethnicity self.inputs['minority status'] = demo.set_minority_status(self.inputs) #requires non white flags be set prior to running set_minority_status
def parse_7_x(self, row): MSA_index = MSA_info() #contains functions for census tract characteristics #connection = connect() #connects to the DB #cur = connection.connect() #creates cursor object connected to HMDAPub2012 sql database, locally hosted postgres self.inputs['year'] = row['asofdate'] #year or application or origination self.inputs['state code'] = row['statecode'] #two digit state code self.inputs['MSA median income'] = row['ffiec_median_family_income'] #median income for the tract/msa self.inputs['state code'] = row['statecode'] #two digit state code self.inputs['county code'] = row['countycode'] self.inputs['census tract number'] = row['censustractnumber'] self.inputs['MSA'] = row['msaofproperty'] self.inputs['state name'] = row['statename'] #two character state abbreviation self.inputs['loan value'] = float(row['loanamount']) #loan value rounded to the nearest thousand self.inputs['action taken'] = int(row['actiontype']) #disposition of the loan application self.inputs['minority percent'] = row['minoritypopulationpct'] #%of population that is minority self.inputs['minority percent index'] = MSA_index.minority_percent(self.inputs) #sets the minority population percent to an index for aggregation self.inputs['tract to MSA income'] = row['tract_to_msa_md_income'] #ratio of tract to msa/md income self.inputs['tract income index'] = MSA_index.tract_to_MSA_income(self.inputs) #sets the tract to msa income ratio to an index for aggregation (low, middle, moderate, high
def parse_A4W(self, row): #this code is from A-4 MSA_index = MSA_info() #contains functions for census tract characteristics demo=demographics() #contains functions for borrower characteristics a_race = [] #race lists will hold 5 integers with 0 replacing a blank entry co_race = [] #race lists will hold 5 integers with 0 replacing a blank entry #fill race lists from the demographics class app_races = [row['applicantrace1'], row['applicantrace2'], row['applicantrace3'],row['applicantrace4'],row['applicantrace5']] co_app_races = [row['coapplicantrace1'], row['coapplicantrace2'], row['coapplicantrace3'],row['coapplicantrace4'],row['coapplicantrace5']] a_race = demo.make_race_list(app_races) #put applicant race codes in a list 0-5, 0 is blank field co_race = demo.make_race_list(co_app_races) #put co-applicant race codes in a list 0-5, 0 is blank field #add data elements to dictionary self.inputs['a_race'] = a_race self.inputs['co_race'] = co_race self.inputs['a ethn'] = row['applicantethnicity'] #ethnicity of the applicant self.inputs['co ethn'] = row['coapplicantethnicity'] #ethnicity of the co-applicant self.inputs['income'] = row['applicantincome'] #relied upon income rounded to the nearest thousand self.inputs['rate spread'] = row['ratespread'] # interest rate spread over APOR if spread is greater than 1.5% self.inputs['loan value'] = float(row['loanamount']) #loan value rounded to the nearest thousand self.inputs['year'] = row['asofdate'] #year or application or origination self.inputs['state code'] = row['statecode'] #two digit state code self.inputs['state name'] = row['statename'] #two character state abbreviation self.inputs['app sex'] = row['applicantsex'] self.inputs['co app sex'] = row['coapplicantsex'] self.inputs['MSA median income'] = row['ffiec_median_family_income'] #median income for the tract/msa self.inputs['minority percent'] = row['minoritypopulationpct'] #%of population that is minority self.inputs['tract to MSA income'] = row['tract_to_msa_md_income'] #ratio of tract to msa/md income self.inputs['sequence'] = row['sequencenumber'] #the sequence number of the loan, used for checking errors self.inputs['preapproval'] = row['preapproval'] self.inputs['action taken'] = row['actiontype'] #self.inputs['lien status'] = row['lienstatus'] self.inputs['tract income index'] = MSA_index.tract_to_MSA_income(self.inputs) #sets the tract to MSA median income ratio to an index number for aggregation self.inputs['income bracket'] = MSA_index.app_income_to_MSA(self.inputs) #sets the applicant income as an index by an applicant's income as a percent of MSA median self.inputs['rate spread index'] = demo.rate_spread_index_11_x(self.inputs['rate spread']) #index of the rate spread for use in the JSON structure self.inputs['minority percent index'] = MSA_index.minority_percent(self.inputs) #sets the minority population percent to an index for aggregation self.inputs['app non white flag'] = demo.set_non_white(a_race) #flags the applicant as non-white if true, used in setting minority status and race self.inputs['co non white flag'] = demo.set_non_white(co_race) #flags the co applicant as non-white if true, used in setting minority status and race self.inputs['minority count'] = demo.minority_count(a_race) #determines if the number of minority races claimed by the applicant is 2 or greater self.inputs['joint status'] = demo.set_joint(self.inputs) #requires non white status flags be set prior to running set_joint self.inputs['race'] = demo.set_race(self.inputs, a_race) #requires joint status be set prior to running set_race self.inputs['ethnicity'] = demo.set_ethnicity(self.inputs) #requires ethnicity be parsed prior to running set_ethnicity self.inputs['minority status'] = demo.set_minority_status(self.inputs) #requires non white flags be set prior to running set_minority_status self.inputs['gender'] = demo.set_gender(self.inputs)
def parse_3_1(self, row): #takes a row of tuples from a table 3-1 query and parses it to the inputs dictionary #parsing inputs for report 3.1 #self.inputs will be used in the aggregation functions #note: sequence number did not exist prior to 2012 and HUD median income became FFIEC median income in 2012 #instantiate classes to set loan variables MSA_index = MSA_info() #contains functions for census tract characteristics demo=demographics() #contains functions for borrower characteristics app_races = [row['applicantrace1'], row['applicantrace2'], row['applicantrace3'],row['applicantrace4'],row['applicantrace5']] co_app_races = [row['coapplicantrace1'], row['coapplicantrace2'], row['coapplicantrace3'],row['coapplicantrace4'],row['coapplicantrace5']] a_race = demo.make_race_list(app_races) #put applicant race codes in a list 0-5, 0 is blank field co_race = demo.make_race_list(co_app_races) #put co-applicant race codes in a list 0-5, 0 is blank field #add data elements to dictionary self.inputs['a_race'] = a_race self.inputs['co_race'] = co_race self.inputs['a ethn'] = row['applicantethnicity'] #ethnicity of the applicant self.inputs['co ethn'] = row['coapplicantethnicity'] #ethnicity of the co-applicant self.inputs['income'] = row['applicantincome'] #relied upon income rounded to the nearest thousand self.inputs['purchaser'] = int(row['purchasertype']) -1 #adjust purchaser index down 1 to match JSON structure self.inputs['loan value'] = float(row['loanamount']) #loan value rounded to the nearest thousand self.inputs['year'] = row['asofdate'] #year or application or origination self.inputs['state code'] = row['statecode'] #two digit state code self.inputs['state name'] = row['statename'] #two character state abbreviation self.inputs['census tract'] = row['censustractnumber'] # this is currently the 7 digit tract used by the FFIEC, it includes a decimal prior to the last two digits self.inputs['county code'] = row['countycode'] #3 digit county code self.inputs['county name'] = row['countyname'] #full text county name self.inputs['MSA median income'] = row['ffiec_median_family_income'] #median income for the tract/msa self.inputs['minority percent'] = row['minoritypopulationpct'] #%of population that is minority self.inputs['tract to MSA income'] = row['tract_to_msa_md_income'] #ratio of tract to msa/md income self.inputs['sequence'] = row['sequencenumber'] #the sequence number of the loan, used for checking errors self.inputs['tract income index'] = MSA_index.tract_to_MSA_income(self.inputs) #sets the tract to MSA median income ratio to an index number for aggregation self.inputs['income bracket'] = MSA_index.app_income_to_MSA(self.inputs) #sets the applicant income as an index by an applicant's income as a percent of MSA median self.inputs['minority percent index'] = MSA_index.minority_percent(self.inputs) #sets the minority population percent to an index for aggregation self.inputs['app non white flag'] = demo.set_non_white(a_race) #flags the applicant as non-white if true, used in setting minority status and race self.inputs['co non white flag'] = demo.set_non_white(co_race) #flags the co applicant as non-white if true, used in setting minority status and race self.inputs['minority count'] = demo.minority_count(a_race) #determines if the number of minority races claimed by the applicant is 2 or greater self.inputs['joint status'] = demo.set_joint(self.inputs) #requires non white status flags be set prior to running set_joint self.inputs['race'] = demo.set_race(self.inputs, a_race) #requires joint status be set prior to running set_race self.inputs['ethnicity'] = demo.set_ethnicity(self.inputs) #requires ethnicity be parsed prior to running set_ethnicity self.inputs['minority status'] = demo.set_minority_status(self.inputs) #requires non white flags be set prior to running set_minority_status
def parse_8_x(self, row): #note: sequence number did not exist prior to 2012 and HUD median income became FFIEC median income in 2012 MSA_index = MSA_info() #contains functions for census tract characteristics demo=demographics() #contains functions for borrower characteristics a_race = [] #race lists will hold 5 integers with 0 replacing a blank entry co_race = [] #race lists will hold 5 integers with 0 replacing a blank entry #fill race lists from the demographics class app_races = [row['applicantrace1'], row['applicantrace2'], row['applicantrace3'],row['applicantrace4'],row['applicantrace5']] co_app_races = [row['coapplicantrace1'], row['coapplicantrace2'], row['coapplicantrace3'],row['coapplicantrace4'],row['coapplicantrace5']] a_race = demo.make_race_list(app_races) #put applicant race codes in a list 0-5, 0 is blank field co_race = demo.make_race_list(co_app_races) #put co-applicant race codes in a list 0-5, 0 is blank field self.inputs['a_race'] = a_race self.inputs['co_race'] = co_race self.inputs['a ethn'] = row['applicantethnicity'] #ethnicity of the applicant self.inputs['co ethn'] = row['coapplicantethnicity'] #ethnicity of the co-applicant self.inputs['app sex'] = row['applicantsex'] self.inputs['co app sex'] = row['coapplicantsex'] self.inputs['income'] = row['applicantincome'] #relied upon income rounded to the nearest thousand self.inputs['denial reason1'] = self.adjust_denial_index(row['denialreason1']) self.inputs['denial reason2'] = self.adjust_denial_index(row['denialreason2']) self.inputs['denial reason3'] = self.adjust_denial_index(row['denialreason3']) self.inputs['year'] = row['asofdate'] #year or application or origination self.inputs['state code'] = row['statecode'] #two digit state code self.inputs['state name'] = row['statename'] #two character state abbreviation self.inputs['census tract'] = row['censustractnumber'] # this is currently the 7 digit tract used by the FFIEC, it includes a decimal prior to the last two digits self.inputs['county code'] = row['countycode'] #3 digit county code self.inputs['county name'] = row['countyname'] #full text county name self.inputs['MSA median income'] = row['ffiec_median_family_income'] #median income for the tract/msa self.inputs['income bracket'] = MSA_index.app_income_to_MSA(self.inputs) #sets the applicant income as an index by an applicant's income as a percent of MSA median self.inputs['app non white flag'] = demo.set_non_white(a_race) #flags the applicant as non-white if true, used in setting minority status and race self.inputs['co non white flag'] = demo.set_non_white(co_race) #flags the co applicant as non-white if true, used in setting minority status and race self.inputs['minority count'] = demo.minority_count(a_race) #determines if the number of minority races claimed by the applicant is 2 or greater self.inputs['joint status'] = demo.set_joint(self.inputs) #requires non white status flags be set prior to running set_joint self.inputs['race'] = demo.set_race(self.inputs, a_race) #requires joint status be set prior to running set_race self.inputs['ethnicity'] = demo.set_ethnicity(self.inputs) #requires ethnicity be parsed prior to running set_ethnicity self.inputs['minority status'] = demo.set_minority_status(self.inputs) #requires non white flags be set prior to running set_minority_status self.inputs['gender'] = demo.set_gender(self.inputs) self.inputs['denial_list'] = self.denial_reasons_list(self.inputs['denial reason1'], self.inputs['denial reason2'], self.inputs['denial reason3'])