def read_from_dir(cls, path, outexcel=False, outpath=None): files = os.listdir(path) if outexcel: moutexcel = Excel(outpath) moutexcel.new().append([[item, item] for item in files], "sheet1") moutexcel.close() else: return files
y += coefs[0]*x1 if coefs[2] in rules3: y += coefs[2]*np.log(x3) else: y += coefs[2]*x3 pdata[''.join(['y',str(i+1)])] = y result.append(one_student_coefs) pdata.to_excel(excel_writer = ''.join([out_path,student,file_name]),index=False) print(result) out_path = 'E:\\temp\\lab\\result.xlsx' mexcel = Excel(out_path) mexcel.new().append(result) mexcel.close() ''' # 1. 正态分布的随机数 mu, sigma = 0, 1 s = np.random.normal(mu, sigma, 1000) print(abs(mu - np.mean(s)) < 0.1, np.mean(s)) # 2. 生成数学表达式 x1 = np.random.randint(0,100,1000) print(np.mean(x1)) y = 2 + 3*x1 + s print(np.mean(y)) mdata = pd.DataFrame({'x1':x1,'y':y})
if re.match('^(-)?\d+((\.|.)\d+)?$',new_item) is not None: new_item = re.sub('.','.',new_item) new_row.append(float(new_item)) else: all = False new_row.append(item) return new_row,all if __name__ == '__main__': filename = r'E:\data\procedure\Process\reduction\data\admincode\2003.xls' acodefile = AdminCodeFile(filename) filename = r'E:\data\procedure\Process\reduction\data\2003_prefecture\3_3_按三次业人员就业状况_地级市_2003.xls' mexcel = WinExcel(filename) mdata = mexcel.read() reduction = CitydataReduction(mdata,acodefile) reduction.reduction() ndata = reduction.second_data print(reduction.second_data) outfile = r'd:\data\demo.xlsx' moutexcel = Excel(outfile) moutexcel.new().append(ndata, 'mysheet') moutexcel.close()