Best Python code snippet using fMBT_python
Course.py
Source:Course.py
...90 for i in data:91 if first:92 first = False93 continue94 name = handle_tr(i[0]).title()95 surname = handle_tr(i[1]).title()96 student_number = str(int(float(i[2])))97 mail = i[3]98 role = 499 username = name.split()[0].lower() + surname.lower()100 password = passwordGenerator(8)101 try:102 self.execute("INSERT INTO members(PersonID, Role, Name, Surname, Username, Password, Email) "103 "values(%s, '%s', '%s', '%s', '%s', '%s', '%s');"104 % (student_number, role, name, surname, username, pas.hash_password(password), mail))105 auth.append((name + " " + surname, mail, password, username))106 except IntegrityError:107 pass108 reg.append(student_number)109 threading.Thread(target=send_mail_first_login, args=(auth, lecturer)).start()...
html2csv.py
Source:html2csv.py
...89 self.processing_table = True90 return91 if not self.table_num:92 self.processing_table = False93 def handle_tr(self, what, _tag, _attrs):94 if self.processing_table:95 if what == "start":96 self.rows.append([])97 def error(self, message):98 print(message, file=sys.stderr)99if __name__ == "__main__":...
mkDataset.py
Source:mkDataset.py
1import numpy2import csv3import cPickle4import datetime as dt5import calendar as cl6dataMonth = cPickle.load(open('data/dumpMonthly.pkl','rb'))7dataDay = cPickle.load(open('data/dumpDaily.pkl','rb'))8# get median for labelling returns9getAll = numpy.asarray([])10for key, value in dataMonth.items():11 getAll = numpy.concatenate([getAll,value.values[:,3]])12median = numpy.median(getAll)13# make dataset14handle_tr = open('data/trainData.dat', 'w')15handle_tr.write("M12,M11,M10,M9,M8,M7,M6,M5,M4,M3,M2,M1,"16 "D15,D14,D13,D12,D11,D10,D9,D8,D7,D6,D5,D4,D3,D2,D1,"17 "Jan,Label,Ticker,Month,Year\n")18handle_ts = open('data/testData.dat', 'w')19handle_ts.write("M12,M11,M10,M9,M8,M7,M6,M5,M4,M3,M2,M1,"20 "D15,D14,D13,D12,D11,D10,D9,D8,D7,D6,D5,D4,D3,D2,D1,"21 "Jan,Label,Ticker,Month,Year\n")22for key, value in dataMonth.items():23 data = []24 for k in xrange(len(dataMonth[key].values[:,3])-12):25 month = dataMonth[key].index[k+12].month26 year = dataMonth[key].index[k+12].year27 # skip current month because insufficient data28 if month!=11 or year!=2014:29 rm = numpy.zeros(12)30 for i in xrange(k,k+12):31 rm[i-k] = dataMonth[key].values[i,3]32 label = dataMonth[key].values[k+12,3] > median33 endday = cl.monthrange(year, month)[1]34 start = dataDay[key].index.searchsorted(dt.datetime(year, month, 1))35 end = dataDay[key].index.searchsorted(dt.datetime(year, month, endday))36 rd = dataDay[key].ix[start:end].values[:,3][-15:]37 if month==1:38 idct = 139 else:40 idct = 041 if len(rd)==15:42 datapoint = numpy.concatenate([rm, rd]).tolist()43 datapoint.append(idct)44 datapoint.append(int(label)+1)45 datapoint.append(key)46 datapoint.append(month)47 datapoint.append(year)48 data.append(datapoint)49 else:50 print "skipped",key,month,year51 train = data[:int(len(data)*0.75)]52 test = data[int(len(data)*0.75):]53 for tr in train:54 handle_tr.write(','.join([str(s) for s in tr])+'\n')55 for ts in test:56 handle_ts.write(','.join([str(s) for s in ts])+'\n')57handle_tr.close()...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!