How to use is_delayed method in localstack

Best Python code snippet using localstack_python

fields_modules.py

Source:fields_modules.py Github

copy

Full Screen

1import numpy as np2import pandas as pd3import time 4def fields_generator(employment_type,has_credit):5 try:6 #print 'begin: ',time.strftime("%H:%M:%S")7 fields = ["employment_type","need","sub_need","income","phone","has_credit"]8 #Basic data9 if has_credit != 1:10 fields.extend(["credit_debt","when_you_got_credit","credit_type","cancelled_credit","is_delayed","delayed_payment","product_entity","credit_limit"])11 #Extra data12 if employment_type == 1:13 fields.extend(["age","university"])14 elif employment_type == 2:15 fields.extend(["age","university","employment_time"])16 elif employment_type in [6,8]:17 fields.extend(["employment_time"])18 #elif employment_type == 5:19 #fields.extend()20 #elif employment_type == 7:21 #fields.extend()22 except Exception,e:23 print "error in collector: ",str(e)24 fields = []25 finally:26 #print 'end: ',time.strftime("%H:%M:%S")27 return fields28"""29 Parameters30"""31#mandatory fields32employment_type_options = [1,2,5,6,7,8]33has_credit_options = [1,2,3]34#need_subneed_options = {"2":[2],"8":[22,24],"4":[33,34],"7":[21,25,26],"1":[27,28,29],"3":[30,31,32]}35phone_options = ['5522208235']36#optional fields37age_pars = [18,25,6]38employment_time_options = [1,3,5,6,8,10,12]39#only if has_credit!=1:40credit_debt_ratio_pars = [0.2,1.0,0.2]41credit_exp_options = [2, 6, 12, 15]42credit_type_options = [1, 2, 3, 4]43is_delayed_options = [1, 2, 3]44delayed_payment_options = [1, 2, 3]45product_entity_options = [10,4,19,3,27,11,24,6,16,9,23,20,26,18,30,8,7,25,2,15,13,17,12,31,22,14,21,5]46credit_limit_pars = [0,15000,1500]47#only if has_credit==348cancelled_credit_options = [1, 2]49#university_options =50#arrays51age_array = np.arange(age_pars[0],age_pars[1],age_pars[2])52credit_type_options = [1, 2, 3, 4]53#product_entity_options = [10,4,19,3,27,11,24,6,16,9,23,20,26,18,30,8,7,25,2,15,13,17,12,31,22,14,21,5]54product_entity_options = [10,8]55credit_exp_options = [2, 6, 12, 15]56credit_debt_ratio_pars = [0.2,1.0,0.2]57credit_debt_ratio_array = np.arange(credit_debt_ratio_pars[0],credit_debt_ratio_pars[1],credit_debt_ratio_pars[2])58credit_limit_pars = [0,10000,3000]59credit_limit_array = np.arange(credit_limit_pars[0],credit_limit_pars[1],credit_limit_pars[2])60def save_matrix(employment_type,has_credit,need_subneed_options):61 print "start:",time.strftime("%H:%M:%S"),"employment_type:",employment_type,"has_credit: ",has_credit62 63 #arrays64 income_pars = [3500,12000,2500]65 phone_options = ['5522208235']66 age_pars = [18,25,6]67 employment_time_options = [1,6,12]68 #only if has_credit!=1:69 credit_debt_ratio_pars = [0.2,0.8,0.2]70 credit_exp_options = [6,12, 15]71 credit_type_options = [1, 2, 3, 4]72 is_delayed_options = [1, 2, 3]73 delayed_payment_options = [1, 2, 3]74 #only if has_credit==375 cancelled_credit_options = [1, 2]76 #university_options =77 income_array = np.arange(income_pars[0],income_pars[1],income_pars[2])78 #income_array = [4000,7000,7500,10000,15000,25000,40000,50000]79 #income_array = [2000.0,3000.0,4000.0,5000.0,7000.0,10000.0]80 81 age_array = np.arange(age_pars[0],age_pars[1],age_pars[2])82 print "age_array:",age_array83 #product_entity_options = [10,4,19,3,27,11,24,6,16,9,23,20,26,18,30,8,7,25,2,15,13,17,12,31,22,14,21,5]84 product_entity_options = [10,8]85 credit_debt_ratio_array = np.arange(credit_debt_ratio_pars[0],credit_debt_ratio_pars[1],credit_debt_ratio_pars[2])86 #credit_limit_pars = [0,10000,3000]87 #credit_limit_array = np.arange(credit_limit_pars[0],credit_limit_pars[1],credit_limit_pars[2])88 credit_limit_array = [7000,7500,10000,15000]89 if has_credit == 2:90 l = []91 for income in income_array:92 n = 093 print "income:",income, n94 #time.sleep(5)95 for phone in phone_options:96 if employment_type in [2,6,8]:97 for employment_time in employment_time_options:98 for credit_type in credit_type_options:99 if credit_type == 1:100 for entity in product_entity_options:101 for credit_exp in credit_exp_options:102 for credit_limit in credit_limit_array:103 for credit_debt_ratio in credit_debt_ratio_array:104 for is_delayed in is_delayed_options:105 if is_delayed in [1,3]:106 if employment_type == 2:107 for age in age_array:108 n = n+1109 #print "n",n110 l.append({'income':income,'phone':phone,'age':age,111 'employment_type':employment_type,'employment_time':employment_time,112 'has_credit':has_credit,'credit_type':credit_type,113 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,114 'when_you_got_credit':credit_exp,115 'credit_limit':credit_limit,116 'is_delayed':is_delayed,'delayed_payment':0})117 else:118 l.append({'income':income,'phone':phone,119 'employment_type':employment_type,'employment_time':employment_time,120 'has_credit':has_credit,'credit_type':credit_type,121 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,122 'when_you_got_credit':credit_exp,123 'credit_limit':credit_limit,124 'is_delayed':is_delayed,'delayed_payment':0})125 else:126 if employment_type == 2:127 for age in age_array:128 n = n+1129 #print "n",n130 l.append({'income':income,'phone':phone,'age':age,131 'employment_type':employment_type,'employment_time':employment_time,132 'has_credit':has_credit,'credit_type':credit_type,133 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,134 'when_you_got_credit':credit_exp,135 'credit_limit':credit_limit,136 'is_delayed':is_delayed,'delayed_payment':1})137 l.append({'income':income,'phone':phone,'age':age,138 'employment_type':employment_type,'employment_time':employment_time,139 'has_credit':has_credit,'credit_type':credit_type,140 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,141 'when_you_got_credit':credit_exp,142 'credit_limit':credit_limit,143 'is_delayed':is_delayed,'delayed_payment':2})144 l.append({'income':income,'phone':phone,'age':age,145 'employment_type':employment_type,'employment_time':employment_time,146 'has_credit':has_credit,'credit_type':credit_type,147 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,148 'when_you_got_credit':credit_exp,149 'credit_limit':credit_limit,150 'is_delayed':is_delayed,'delayed_payment':3})151 else:152 l.append({'income':income,'phone':phone,153 'employment_type':employment_type,'employment_time':employment_time,154 'has_credit':has_credit,'credit_type':credit_type,155 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,156 'when_you_got_credit':credit_exp,157 'credit_limit':credit_limit,158 'is_delayed':is_delayed,'delayed_payment':1})159 l.append({'income':income,'phone':phone,160 'employment_type':employment_type,'employment_time':employment_time,161 'has_credit':has_credit,'credit_type':credit_type,162 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,163 'when_you_got_credit':credit_exp,164 'credit_limit':credit_limit,165 'is_delayed':is_delayed,'delayed_payment':2})166 l.append({'income':income,'phone':phone,167 'employment_type':employment_type,'employment_time':employment_time,168 'has_credit':has_credit,'credit_type':credit_type,169 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,170 'when_you_got_credit':credit_exp,171 'credit_limit':credit_limit,172 'is_delayed':is_delayed,'delayed_payment':3})173 else:174 for credit_exp in credit_exp_options:175 for credit_debt_ratio in credit_debt_ratio_array:176 for is_delayed in is_delayed_options:177 if is_delayed in [1,3]:178 if employment_type == 2:179 for age in age_array:180 n = n+1181 #print "n",n182 l.append({'income':income,'phone':phone,'age':age,183 'employment_type':employment_type,'employment_time':employment_time,184 'has_credit':has_credit,'credit_type':credit_type,185 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,186 'when_you_got_credit':credit_exp,187 'is_delayed':is_delayed,'delayed_payment':0})188 else:189 l.append({'income':income,'phone':phone,190 'employment_type':employment_type,'employment_time':employment_time,191 'has_credit':has_credit,'credit_type':credit_type,192 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,193 'when_you_got_credit':credit_exp,194 'is_delayed':is_delayed,'delayed_payment':0})195 else:196 if employment_type == 2:197 for age in age_array:198 n = n+1199 #print "n",n200 l.append({'income':income,'phone':phone,'age':age,201 'employment_type':employment_type,'employment_time':employment_time,202 'has_credit':has_credit,'credit_type':credit_type,203 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,204 'when_you_got_credit':credit_exp,205 'is_delayed':is_delayed,'delayed_payment':1})206 l.append({'income':income,'phone':phone,'age':age,207 'employment_type':employment_type,'employment_time':employment_time,208 'has_credit':has_credit,'credit_type':credit_type,209 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,210 'when_you_got_credit':credit_exp,211 'is_delayed':is_delayed,'delayed_payment':2})212 l.append({'income':income,'phone':phone,'age':age,213 'employment_type':employment_type,'employment_time':employment_time,214 'has_credit':has_credit,'credit_type':credit_type,215 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,216 'when_you_got_credit':credit_exp,217 'is_delayed':is_delayed,'delayed_payment':3})218 else:219 l.append({'income':income,'phone':phone,220 'employment_type':employment_type,'employment_time':employment_time,221 'has_credit':has_credit,'credit_type':credit_type,222 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,223 'when_you_got_credit':credit_exp,224 'is_delayed':is_delayed,'delayed_payment':1})225 l.append({'income':income,'phone':phone,226 'employment_type':employment_type,'employment_time':employment_time,227 'has_credit':has_credit,'credit_type':credit_type,228 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,229 'when_you_got_credit':credit_exp,230 'is_delayed':is_delayed,'delayed_payment':2})231 l.append({'income':income,'phone':phone,232 'employment_type':employment_type,'employment_time':employment_time,233 'has_credit':has_credit,'credit_type':credit_type,234 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,235 'when_you_got_credit':credit_exp,236 'is_delayed':is_delayed,'delayed_payment':3})237 elif employment_type == 1:238 for age in age_array:239 for credit_type in credit_type_options:240 if credit_type == 1:241 for entity in product_entity_options:242 for credit_exp in credit_exp_options:243 for credit_limit in credit_limit_array:244 for credit_debt_ratio in credit_debt_ratio_array:245 for is_delayed in is_delayed_options:246 if is_delayed in [1,3]:247 l.append({'income':income,'phone':phone,'age':age,248 'employment_type':employment_type,249 'has_credit':has_credit,'credit_type':credit_type,250 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,251 'when_you_got_credit':credit_exp,252 'credit_limit':credit_limit,253 'is_delayed':is_delayed,'delayed_payment':0})254 else:255 l.append({'income':income,'phone':phone,'age':age,256 'employment_type':employment_type,257 'has_credit':has_credit,'credit_type':credit_type,258 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,259 'when_you_got_credit':credit_exp,260 'credit_limit':credit_limit,261 'is_delayed':is_delayed,'delayed_payment':1})262 l.append({'income':income,'phone':phone,'age':age,263 'employment_type':employment_type,264 'has_credit':has_credit,'credit_type':credit_type,265 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,266 'when_you_got_credit':credit_exp,267 'credit_limit':credit_limit,268 'is_delayed':is_delayed,'delayed_payment':2})269 l.append({'income':income,'phone':phone,'age':age,270 'employment_type':employment_type,271 'has_credit':has_credit,'credit_type':credit_type,272 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,273 'when_you_got_credit':credit_exp,274 'credit_limit':credit_limit,275 'is_delayed':is_delayed,'delayed_payment':3})276 else:277 for credit_exp in credit_exp_options:278 for credit_limit in credit_limit_array:279 for credit_debt_ratio in credit_debt_ratio_array:280 for is_delayed in is_delayed_options:281 if is_delayed in [1,3]:282 l.append({'income':income,'age':age,'phone':phone,283 'employment_type':employment_type,284 'has_credit':has_credit,'credit_type':credit_type,285 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,286 'when_you_got_credit':credit_exp,287 'credit_limit':credit_limit,288 'is_delayed':is_delayed,'delayed_payment':0})289 else:290 l.append({'income':income,'age':age,'phone':phone,291 'employment_type':employment_type,292 'has_credit':has_credit,'credit_type':credit_type,293 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,294 'when_you_got_credit':credit_exp,295 'credit_limit':credit_limit,296 'is_delayed':is_delayed,'delayed_payment':1})297 l.append({'income':income,'age':age,'phone':phone,298 'employment_type':employment_type,299 'has_credit':has_credit,'credit_type':credit_type,300 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,301 'when_you_got_credit':credit_exp,302 'credit_limit':credit_limit,303 'is_delayed':is_delayed,'delayed_payment':2})304 l.append({'income':income,'age':age,'phone':phone,305 'employment_type':employment_type,306 'has_credit':has_credit,'credit_type':credit_type,307 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,308 'when_you_got_credit':credit_exp,309 'credit_limit':credit_limit,310 'is_delayed':is_delayed,'delayed_payment':3})311 elif employment_type == 5:312 for credit_type in credit_type_options:313 if credit_type == 1:314 for entity in product_entity_options:315 for credit_exp in credit_exp_options:316 for credit_limit in credit_limit_array:317 for credit_debt_ratio in credit_debt_ratio_array:318 for is_delayed in is_delayed_options:319 if is_delayed in [1,3]:320 l.append({'income':income,'phone':phone,321 'employment_type':employment_type,322 'has_credit':has_credit,'credit_type':credit_type,323 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,324 'when_you_got_credit':credit_exp,325 'credit_limit':credit_limit,326 'is_delayed':is_delayed,'delayed_payment':0})327 else:328 l.append({'income':income,'phone':phone,329 'employment_type':employment_type,330 'has_credit':has_credit,'credit_type':credit_type,331 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,332 'when_you_got_credit':credit_exp,333 'credit_limit':credit_limit,334 'is_delayed':is_delayed,'delayed_payment':1})335 l.append({'income':income,'phone':phone,336 'employment_type':employment_type,337 'has_credit':has_credit,'credit_type':credit_type,338 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,339 'when_you_got_credit':credit_exp,340 'credit_limit':credit_limit,341 'is_delayed':is_delayed,'delayed_payment':2})342 l.append({'income':income,'phone':phone,343 'employment_type':employment_type,344 'has_credit':has_credit,'credit_type':credit_type,345 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,346 'when_you_got_credit':credit_exp,347 'credit_limit':credit_limit,348 'is_delayed':is_delayed,'delayed_payment':3})349 else:350 for credit_exp in credit_exp_options:351 for credit_limit in credit_limit_array:352 for credit_debt_ratio in credit_debt_ratio_array:353 for is_delayed in is_delayed_options:354 if is_delayed in [1,3]:355 l.append({'income':income,'phone':phone,356 'employment_type':employment_type,'employment_time':0,357 'has_credit':has_credit,'credit_type':credit_type,358 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,359 'when_you_got_credit':credit_exp,360 'credit_limit':credit_limit,361 'is_delayed':is_delayed,'delayed_payment':0})362 else:363 l.append({'income':income,'phone':phone,364 'employment_type':employment_type,'employment_time':0,365 'has_credit':has_credit,'credit_type':credit_type,366 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,367 'when_you_got_credit':credit_exp,368 'credit_limit':credit_limit,369 'is_delayed':is_delayed,'delayed_payment':1})370 l.append({'income':income,'phone':phone,371 'employment_type':employment_type,'employment_time':0,372 'has_credit':has_credit,'credit_type':credit_type,373 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,374 'when_you_got_credit':credit_exp,375 'credit_limit':credit_limit,376 'is_delayed':is_delayed,'delayed_payment':2})377 l.append({'income':income,'phone':phone,378 'employment_type':employment_type,'employment_time':0,379 'has_credit':has_credit,'credit_type':credit_type,380 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,381 'when_you_got_credit':credit_exp,382 'credit_limit':credit_limit,383 'is_delayed':is_delayed,'delayed_payment':3})384 for need in need_subneed_options.keys():385 for subneed in need_subneed_options[need]:386 data = pd.DataFrame(l)387 data['need'] = need388 data['sub_need'] = subneed389 data['Expected_result'] = np.nan390 data['Expected_list'] = np.nan391 semipath = str(need)+'/'+str(subneed)+'/'+str(has_credit)+'/matrix'392 #import code; code.interact(local=locals())393 if employment_type == 1:394 data.to_csv('TEST_MATRIX/students/'+semipath+'.csv')395 elif employment_type == 2:396 data.to_csv('TEST_MATRIX/students_work/'+semipath+'.csv')397 elif employment_type == 5:398 data.to_csv('TEST_MATRIX/housewifes/'+semipath+'.csv')399 elif employment_type == 6:400 data.to_csv('TEST_MATRIX/employees/'+semipath+'.csv')401 elif employment_type == 7:402 data.to_csv('TEST_MATRIX/no_employees/'+semipath+'.csv')403 elif employment_type == 8:404 data.to_csv('TEST_MATRIX/freelancers/'+semipath+'.csv')405 else:406 print "unknown employment_type: ", employment_type407 elif has_credit == 3:408 l = []409 for income in income_array:410 for phone in phone_options:411 if employment_type in [2,6,8]:412 for employment_time in employment_time_options:413 for credit_type in credit_type_options:414 if credit_type == 1:415 for entity in product_entity_options:416 for credit_exp in credit_exp_options:417 for credit_limit in credit_limit_array:418 for credit_debt_ratio in credit_debt_ratio_array:419 for cancelled_credit in cancelled_credit_options:420 for is_delayed in is_delayed_options:421 if is_delayed in [1,3]:422 if employment_type == 2:423 for age in age_array:424 l.append({'income':income,'phone':phone,'age':age,425 'employment_type':employment_type,'employment_time':employment_time,426 'has_credit':has_credit,'credit_type':credit_type,427 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,428 'when_you_got_credit':credit_exp,429 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,430 'is_delayed':is_delayed,'delayed_payment':0})431 else:432 l.append({'income':income,'phone':phone,433 'employment_type':employment_type,'employment_time':employment_time,434 'has_credit':has_credit,'credit_type':credit_type,435 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,436 'when_you_got_credit':credit_exp,437 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,438 'is_delayed':is_delayed,'delayed_payment':0})439 else:440 if employment_type == 2:441 for age in age_array:442 l.append({'income':income,'phone':phone,'age':age,443 'employment_type':employment_type,'employment_time':employment_time,444 'has_credit':has_credit,'credit_type':credit_type,445 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,446 'when_you_got_credit':credit_exp,'cancelled_credit':cancelled_credit,447 'credit_limit':credit_limit,448 'is_delayed':is_delayed,'delayed_payment':1})449 l.append({'income':income,'phone':phone,'age':age,450 'employment_type':employment_type,'employment_time':employment_time,451 'has_credit':has_credit,'credit_type':credit_type,452 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,453 'when_you_got_credit':credit_exp,'cancelled_credit':cancelled_credit,454 'credit_limit':credit_limit,455 'is_delayed':is_delayed,'delayed_payment':2})456 l.append({'income':income,'phone':phone,'age':age,457 'employment_type':employment_type,'employment_time':employment_time,458 'has_credit':has_credit,'credit_type':credit_type,459 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,460 'when_you_got_credit':credit_exp,461 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,462 'is_delayed':is_delayed,'delayed_payment':3})463 else:464 l.append({'income':income,'phone':phone,465 'employment_type':employment_type,'employment_time':employment_time,466 'has_credit':has_credit,'credit_type':credit_type,467 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,468 'when_you_got_credit':credit_exp,'cancelled_credit':cancelled_credit,469 'credit_limit':credit_limit,470 'is_delayed':is_delayed,'delayed_payment':1})471 l.append({'income':income,'phone':phone,472 'employment_type':employment_type,'employment_time':employment_time,473 'has_credit':has_credit,'credit_type':credit_type,474 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,475 'when_you_got_credit':credit_exp,'cancelled_credit':cancelled_credit,476 'credit_limit':credit_limit,477 'is_delayed':is_delayed,'delayed_payment':2})478 l.append({'income':income,'phone':phone,479 'employment_type':employment_type,'employment_time':employment_time,480 'has_credit':has_credit,'credit_type':credit_type,481 'product_entity':entity,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,482 'when_you_got_credit':credit_exp,483 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,484 'is_delayed':is_delayed,'delayed_payment':3})485 else:486 for credit_exp in credit_exp_options:487 for credit_debt_ratio in credit_debt_ratio_array:488 for cancelled_credit in cancelled_credit_options:489 for is_delayed in is_delayed_options:490 if is_delayed in [1,3]:491 if employment_type == 2:492 for age in age_array:493 l.append({'income':income,'phone':phone,'age':age,494 'employment_type':employment_type,'employment_time':employment_time,495 'has_credit':has_credit,'credit_type':credit_type,496 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,497 'when_you_got_credit':credit_exp,'cancelled_credit':cancelled_credit,498 'is_delayed':is_delayed,'delayed_payment':0})499 else:500 l.append({'income':income,'phone':phone,501 'employment_type':employment_type,'employment_time':employment_time,502 'has_credit':has_credit,'credit_type':credit_type,503 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,504 'when_you_got_credit':credit_exp,'cancelled_credit':cancelled_credit,505 'is_delayed':is_delayed,'delayed_payment':0})506 else:507 if employment_type == 2:508 for age in age_array:509 l.append({'income':income,'phone':phone,'age':age,510 'employment_type':employment_type,'employment_time':employment_time,511 'has_credit':has_credit,'credit_type':credit_type,512 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,513 'cancelled_credit':cancelled_credit,514 'when_you_got_credit':credit_exp,515 'is_delayed':is_delayed,'delayed_payment':1})516 l.append({'income':income,'phone':phone,'age':age,517 'employment_type':employment_type,'employment_time':employment_time,518 'has_credit':has_credit,'credit_type':credit_type,519 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,520 'cancelled_credit':cancelled_credit,521 'when_you_got_credit':credit_exp,522 'is_delayed':is_delayed,'delayed_payment':2})523 l.append({'income':income,'phone':phone,'age':age,524 'employment_type':employment_type,'employment_time':employment_time,525 'has_credit':has_credit,'credit_type':credit_type,526 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,527 'cancelled_credit':cancelled_credit,528 'when_you_got_credit':credit_exp,529 'is_delayed':is_delayed,'delayed_payment':3})530 else:531 l.append({'income':income,'phone':phone,532 'employment_type':employment_type,'employment_time':employment_time,533 'has_credit':has_credit,'credit_type':credit_type,534 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,535 'cancelled_credit':cancelled_credit,536 'when_you_got_credit':credit_exp,537 'is_delayed':is_delayed,'delayed_payment':1})538 l.append({'income':income,'phone':phone,539 'employment_type':employment_type,'employment_time':employment_time,540 'has_credit':has_credit,'credit_type':credit_type,541 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,542 'cancelled_credit':cancelled_credit,543 'when_you_got_credit':credit_exp,544 'is_delayed':is_delayed,'delayed_payment':2})545 l.append({'income':income,'phone':phone,546 'employment_type':employment_type,'employment_time':employment_time,547 'has_credit':has_credit,'credit_type':credit_type,548 'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,549 'cancelled_credit':cancelled_credit,550 'when_you_got_credit':credit_exp,551 'is_delayed':is_delayed,'delayed_payment':3})552 else:553 for age in age_array:554 for credit_type in credit_type_options:555 if credit_type == 1:556 for entity in product_entity_options:557 for credit_exp in credit_exp_options:558 for credit_limit in credit_limit_array:559 for credit_debt_ratio in credit_debt_ratio_array:560 for cancelled_credit in cancelled_credit_options:561 for is_delayed in is_delayed_options:562 if is_delayed in [1,3]:563 l.append({'income':income,'phone':phone,'age':age,564 'employment_type':employment_type,'employment_time':0,565 'has_credit':has_credit,'credit_type':credit_type,566 'product_entity':entity,'credit_debt':income*credit_debt_ratio,567 'credit_debt_ratio':credit_debt_ratio,568 'when_you_got_credit':credit_exp,569 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,570 'is_delayed':is_delayed,'delayed_payment':0})571 else:572 l.append({'income':income,'phone':phone,'age':age,573 'employment_type':employment_type,'employment_time':0,574 'has_credit':has_credit,'credit_type':credit_type,575 'product_entity':entity,'credit_debt':income*credit_debt_ratio,576 'credit_debt_ratio':credit_debt_ratio,577 'when_you_got_credit':credit_exp,578 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,579 'is_delayed':is_delayed,'delayed_payment':1})580 l.append({'income':income,'phone':phone,'age':age,581 'employment_type':employment_type,'employment_time':0,582 'has_credit':has_credit,'credit_type':credit_type,583 'product_entity':entity,'credit_debt':income*credit_debt_ratio,584 'credit_debt_ratio':credit_debt_ratio,585 'when_you_got_credit':credit_exp,586 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,587 'is_delayed':is_delayed,'delayed_payment':2})588 l.append({'income':income,'phone':phone,'age':age,589 'employment_type':employment_type,'employment_time':0,590 'has_credit':has_credit,'credit_type':credit_type,591 'product_entity':entity,'credit_debt':income*credit_debt_ratio,592 'credit_debt_ratio':credit_debt_ratio,593 'when_you_got_credit':credit_exp,594 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,595 'is_delayed':is_delayed,'delayed_payment':3})596 else:597 for credit_exp in credit_exp_options:598 for credit_limit in credit_limit_array:599 for credit_debt_ratio in credit_debt_ratio_array:600 for cancelled_credit in cancelled_credit_options:601 for is_delayed in is_delayed_options:602 if is_delayed in [1,3]:603 l.append({'income':income,'age':age,'phone':phone,604 'employment_type':employment_type,'employment_time':0,605 'has_credit':has_credit,'credit_type':credit_type,606 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,607 'when_you_got_credit':credit_exp,608 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,609 'is_delayed':is_delayed,'delayed_payment':0})610 else:611 l.append({'income':income,'age':age,'phone':phone,612 'employment_type':employment_type,'employment_time':0,613 'has_credit':has_credit,'credit_type':credit_type,614 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,615 'when_you_got_credit':credit_exp,616 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,617 'is_delayed':is_delayed,'delayed_payment':1})618 l.append({'income':income,'age':age,'phone':phone,619 'employment_type':employment_type,'employment_time':0,620 'has_credit':has_credit,'credit_type':credit_type,621 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,622 'when_you_got_credit':credit_exp,623 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,624 'is_delayed':is_delayed,'delayed_payment':2})625 l.append({'income':income,'age':age,'phone':phone,626 'employment_type':employment_type,'employment_time':0,627 'has_credit':has_credit,'credit_type':credit_type,628 'product_entity':0,'credit_debt':income*credit_debt_ratio,'credit_debt_ratio':credit_debt_ratio,629 'when_you_got_credit':credit_exp,630 'credit_limit':credit_limit,'cancelled_credit':cancelled_credit,631 'is_delayed':is_delayed,'delayed_payment':3})632 for need in need_subneed_options.keys():633 for subneed in need_subneed_options[need]:634 data = pd.DataFrame(l)635 data['need'] = need636 data['sub_need'] = subneed637 data['Expected_result'] = np.nan638 data['Expected_list'] = np.nan639 semipath = str(need)+'/'+str(subneed)+'/'+str(has_credit)+'/matrix'640 #import code; code.interact(local=locals())641 if employment_type == 1:642 data.to_csv('TEST_MATRIX/students/'+semipath+'.csv')643 #import code; code.interact(local=locals())644 elif employment_type == 2:645 data.to_csv('TEST_MATRIX/students_work/'+semipath+'.csv')646 elif employment_type == 5:647 data.to_csv('TEST_MATRIX/housewifes/'+semipath+'.csv')648 elif employment_type == 6:649 data.to_csv('TEST_MATRIX/employees/'+semipath+'.csv')650 elif employment_type == 7:651 data.to_csv('TEST_MATRIX/no_employees/'+semipath+'.csv')652 elif employment_type == 8:653 data.to_csv('TEST_MATRIX/freelancers/'+semipath+'.csv')654 else:655 print "unknown employment_type: ", employment_type656 elif has_credit==1:657 l = []658 for income in income_array:659 for phone in phone_options:660 if employment_type in [5,6,8]:661 for employment_time in employment_time_options:662 l.append({'income':income,663 'phone':phone,'employment_time':employment_time,664 'employment_type':employment_type,'has_credit':has_credit})665 else:666 for age in age_array:667 l.append({'income':income,'age':age,668 'phone':phone,'employment_type':employment_type,'employment_time':0,669 'has_credit':has_credit,})670 for need in need_subneed_options.keys():671 for subneed in need_subneed_options[need]:672 data = pd.DataFrame(l)673 data['need'] = need674 data['sub_need'] = subneed675 data['Expected_result'] = np.nan676 data['Expected_list'] = np.nan677 semipath = str(need)+'/'+str(subneed)+'/'+str(has_credit)+'/matrix'678 #import code; code.interact(local=locals())679 if employment_type == 1:680 data.to_csv('TEST_MATRIX/students/'+semipath+'.csv')681 elif employment_type == 2:682 data.to_csv('TEST_MATRIX/students_work/'+semipath+'.csv')683 elif employment_type == 5:684 data.to_csv('TEST_MATRIX/housewifes/'+semipath+'.csv')685 elif employment_type == 6:686 data.to_csv('TEST_MATRIX/employees/'+semipath+'.csv')687 elif employment_type == 7:688 data.to_csv('TEST_MATRIX/no_employees/'+semipath+'.csv')689 elif employment_type == 8:690 data.to_csv('TEST_MATRIX/freelancers/'+semipath+'.csv')691 else:692 print "unknown employment_type: ", employment_type...

Full Screen

Full Screen

low_stock.py

Source:low_stock.py Github

copy

Full Screen

...148 :type: str149 """150 self._print_flag = print_flag151 @property152 def is_delayed(self):153 """Gets the is_delayed of this LowStock. # noqa: E501154 :return: The is_delayed of this LowStock. # noqa: E501155 :rtype: bool156 """157 return self._is_delayed158 @is_delayed.setter159 def is_delayed(self, is_delayed):160 """Sets the is_delayed of this LowStock.161 :param is_delayed: The is_delayed of this LowStock. # noqa: E501162 :type: bool163 """164 self._is_delayed = is_delayed165 @property166 def create_date(self):167 """Gets the create_date of this LowStock. # noqa: E501168 :return: The create_date of this LowStock. # noqa: E501169 :rtype: datetime170 """171 return self._create_date172 @create_date.setter173 def create_date(self, create_date):...

Full Screen

Full Screen

percentageofdelay.py

Source:percentageofdelay.py Github

copy

Full Screen

1def percentageofdelay(src,dest):2 flightsinfo = pd.read_csv("drive/My Drive/flights.csv",nrows=200000)3 airport = pd.read_csv('drive/My Drive/airports.csv')4 airlines = pd.read_csv('drive/My Drive/airlines.csv')5 flights=flightsinfo6 Flights1 = flightsinfo7 Flights1=flightsinfo.drop(['YEAR','MONTH','DAY','DAY_OF_WEEK','TAIL_NUMBER','DEPARTURE_TIME','WHEELS_OFF','WHEELS_ON','SCHEDULED_ARRIVAL','ARRIVAL_TIME','CANCELLATION_REASON','AIR_SYSTEM_DELAY','SECURITY_DELAY','AIRLINE_DELAY','LATE_AIRCRAFT_DELAY','WEATHER_DELAY'], axis = 1)8 Flights1['Is_Delayed'] = np.where(Flights1['ARRIVAL_DELAY']<=0, 0,1)9 Flights1=Flights1.loc[(Flights1['ORIGIN_AIRPORT'] == src) & (Flights1['DESTINATION_AIRPORT'] == dest)]10 totalcount=Flights1['Is_Delayed'].count()11 delayedcount=Flights1.loc[(Flights1['Is_Delayed'] == 1)]['Is_Delayed'].count()12 nodelayedcount=Flights1.loc[(Flights1['Is_Delayed'] == 0)]['Is_Delayed'].count()13 axis = plt.subplots(figsize=(10,14))14 Name = ['Delayed','Not Delayed']15 values = [(delayedcount/totalcount)*100,(nodelayedcount/totalcount)*100]16 plt.pie(values,labels=Name,autopct='%5.0f%%')17 plt.show()18 plt.savefig('drive/My Drive/percentageofdelayimage.png')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful