Best Python code snippet using pandera_python
compare_mcs_installations.py
Source:compare_mcs_installations.py
...41 )42 schema_withchecks = pa.DataFrameSchema(43 {44 "Company Name": pa.Column(str),45 "MCS certificate number": pa.Column(str, checks=pa.Check.str_contains("-")),46 "Add 1": pa.Column(str),47 "Add2": pa.Column(str, nullable=True),48 "Town": pa.Column(str, nullable=True),49 "County": pa.Column(str, nullable=True),50 "PCode": pa.Column(str, checks=pa.Check.str_length(6, 8)),51 "Solar Thermal": pa.Column(checks=pa.Check.str_contains("YES|NO")),52 "Wind Turbines": pa.Column(checks=pa.Check.str_contains("YES|NO")),53 "Air Source Heat Pumps": pa.Column(checks=pa.Check.str_contains("YES|NO")),54 "Exhaust Air Heat Pumps": pa.Column(checks=pa.Check.str_contains("YES|NO")),55 "Biomass": pa.Column(checks=pa.Check.str_contains("YES|NO")),56 "Solar Photovoltaics": pa.Column(checks=pa.Check.str_contains("YES|NO")),57 "Micro CHP": pa.Column(checks=pa.Check.str_contains("YES|NO")),58 "SolarAssistedHeatPump": pa.Column(checks=pa.Check.str_contains("YES|NO")),59 "GasAbsorptionHeatPump": pa.Column(checks=pa.Check.str_contains("YES|NO")),60 "Ground/Water Source Heat Pump": pa.Column(61 checks=pa.Check.str_contains("YES|NO")62 ),63 "Battery Storage": pa.Column(checks=pa.Check.str_contains("YES|NO")),64 "Eastern Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),65 "East Midlands Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),66 "London Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),67 "North East Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),68 "North West Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),69 "South East Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),70 "South West Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),71 "West Midlands Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),72 "Yorkshire Humberside Region": pa.Column(73 checks=pa.Check.str_contains("YES|NO")74 ),75 "Northern Ireland Region": pa.Column(76 checks=pa.Check.str_contains("YES|NO")77 ),78 "Scotland Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),79 "Wales Region": pa.Column(checks=pa.Check.str_contains("YES|NO")),80 "Effective From": pa.Column(81 checks=[82 pa.Check(lambda s: s.dt.year >= 1900),83 pa.Check(lambda s: s.dt.year <= datetime.now().year),84 ]85 ),86 "Consumer Code": pa.Column(str, checks=pa.Check.str_length(3, 4)),87 "Certification Body": pa.Column(str),88 }89 )90 try:91 mcs_installers_no_unspecified = schema_withchecks.validate(92 mcs_installers_no_unspecified, lazy=True93 )...
functions.py
Source:functions.py
...55 return days56# def filter_input(string input) {57# input_is_dangerous = true58# while (input_is_dangerous) {59# if (str_contains(input, '(')) {60# input = str_replace('(', '', input)61# } else if (str_contains(input, ')')) {62# input = str_replace(')', '', input)63# } else if (str_contains(input, '')) {64# input = str_replace('', '', input)65# } else if (str_contains(input, '{')) {66# input = str_replace('{', '', input)67# } else if (str_contains(input, '}')) {68# input = str_replace('}', '', input)69# } else if (str_contains(input, '[')) {70# input = str_replace('[', '', input)71# } else if (str_contains(input, ']')) {72# input = str_replace(']', '', input)73# } else if (str_contains(input, 'SELECT')) {74# input = str_replace('SELECT', '', input)75# } else if (str_contains(input, '\'')) {76# input = str_replace('\'', '', input)77# } else if (str_contains(input, '"')) {78# input = str_replace('"', '', input)79# } else {80# input_is_dangerous = false81# }82# }83# return input84# }...
main_plot.py
Source:main_plot.py
1import os2import matplotlib.pyplot as plt3from constants import pkl_name, RunParams4from serializer import load5def data_load(alg: str, data_set: str, params: RunParams):6 data, results = pkl_name(alg, data_set, params)7 model = load(results)8 lable = "RMSE-{}-{} - lr={} k={}".format(alg,data_set, params.lr, params.k, params.reg) \9 if alg == 'mf' else\10 "RMSE-{}-{} - k={} lambda={}".format(alg,data_set, params.k, params.reg)11 return model, lable12algs = frozenset(['mf', 'Adam-AutoRec'])13def draw_plots(algs=set({}), data_set='1m', limit=100, minimum_itres=5, str_contains=None, str_exclude=None):14 models = os.listdir('pickle_res/{}'.format(data_set))15 min = 20016 min_params = None17 best_model = None18 for model in models:19 if model == 'old':20 continue21 filename = model.replace(".pkl", "")22 alg, lr, lf, reg = filename.split("_")23 print(filename, str_contains in filename, (str_contains and str_contains in filename) and not (str_exclude and str_exclude in filename))24 if alg in algs or ((str_contains and str_contains in filename) and not (str_exclude and str_exclude in filename)):25 params = RunParams(float(lr), int(lf), float(reg), 0)26 res_init_params, label = data_load(alg, data_set, params)27 y = [r[1] for r in res_init_params]28 x = [r[0] for r in res_init_params]29 if len(y) < minimum_itres:30 continue31 for value in y:32 if value < min:33 min = value34 min_params = params35 best_model = filename36 plt.plot(x[:limit], y[:limit], label=label.replace("Adam-", ""))37 print("best params: {}, {}, {}".format(min, min_params, best_model))38 plt.legend()39 plt.ylabel('RMSE')40 plt.xlabel('Iterations')41 plt.title("Data set: {}, algorithms:{}".format(data_set, list(algs)))42 plt.show()43if __name__ == '__main__':44 # draw_plots(algs=frozenset({'Adam-AutoRec'}), data_set='1m', limit=200)45 # draw_plots(algs=frozenset({'New-AutoRec'}), data_set='1m', limit=200)46 # draw_plots(algs={'mf'}, data_set='1m', limit=200)47 draw_plots(data_set='1m', limit=500, str_contains="Updated")48 # draw_plots(algs=frozenset({}), data_set='100k', limit=400, str_contains="-f")49 # draw_plots(algs={}, data_set='1m', limit=400, str_contains="New-AutoRec-", str_exclude="")50 # draw_plots(algs={}, data_set='100k', limit=400, str_contains="fsigmoid-gselu", str_exclude="")51 # draw_plots(algs=frozenset({'mf'}), data_set='100k', limit=200)52 # draw_plots(algs=frozenset({'mf'}), limit=200)...
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!!