[Python] curve fitting
๋ฐ์ด ์์ฐ์์ e์ธ ์ง์ํจ์ x = np.arange(-2, 4, 0.1) y = np.exp(x) plt.plot(x, y, label='e^x') plt.legend() plt.show() ์์ฐ๋ก๊ทธ ํจ์ x = np.arange(0.1, 4, 0.1) y = np.log(x) plt.plot(x, y, label='y = log x') plt.legend() plt.show() ์ง์ ํจ์ curve fitting from scipy.optimize import curve_fit import matplotlib.pyplot as plt # a*e^(-b*x)+c def func1(x, a, b, c): return a * np.exp(-b * x) + c def func2(x, a, b, c): ret..
[Python] XlsxWriter - Excel ๋ค๋ฃจ๊ธฐ
Pandas - Dataframe๊ณผ ํจ๊ป ์ฌ์ฉํ๊ธฐ writer = pd.ExcelWriter(out_file, engine='xlsxwriter') df.to_excel(writer, sheet_name='Sheet1', freeze_panes = (1, 0), index=False) workbook = writer.book worksheet = writer.sheets['Sheet1'] worksheet.set_zoom(80) # zoom ์ค์ # row, col, width, format worksheet.set_column(0, 0, 10, workbook.add_format({'num_format': '#,##0', 'border': 1, 'align': 'center', 'text_wrap': ..
[Python] Pandas - Dataframe : apply, lambda ์ด์ฉํ ๊ฐ ๋ณ๊ฒฝ
df = pd.DataFrame({'test': [ '1,000' ,'20000' ,'3000' ,'4,330' ]}) df['test'] = df.apply(lambda x: x['test'].replace(",", "").replace(" ", "") if x['test'] else '', axis=1) for๋ฌธ์์ ๋ณ๊ฒฝํ๊ธฐ for i, row in df.iterrows(): row.loc[i, 'age2'] = row['age'] + 10