How to use print_tb method in Slash

Best Python code snippet using slash

main.py

Source:main.py Github

copy

Full Screen

...73 end = datetime(2016, 6, 12)74 df = web.DataReader("078930.KS", "yahoo", start, end)75 con = sqlite3.connect("./kospi.db")76 df.to_sql('078930', con, if_exists='replace')77 self.print_tb(" db is writed ", str(df))78 con.close()79 @clear_textbrowser_decorator80 def on_clicked_read_sql_test(self):81 con = sqlite3.connect("./kospi.db")82 readed_df = pd.read_sql("SELECT * FROM '078930'", con, index_col='Date')83 self.print_tb(" db is readed ", str(readed_df))84 con.close()85 @clear_textbrowser_decorator86 def on_clicked_stategy_1_btn(self):87 strategy1.strategy1(self)88 @clear_textbrowser_decorator89 def on_clicked_stategy_2_btn(self):90 strategy2.strategy2(self)91 @clear_textbrowser_decorator92 def on_clicked_stategy_3_btn(self):93 strategy3.strategy3(self)94 @clear_textbrowser_decorator95 def on_clicked_df_multiple_btn(self):96 a = pd.DataFrame([[1, 2], [3, np.nan, ], [5, 6]], columns=["a", "b"])97 b = pd.DataFrame([[1, 2], [3, 4, ], [5, 6]], columns=["a", "b"]) * 1098 self.print_tb("a is ", str(a))99 self.print_tb("b is ", str(b))100 self.print_tb("a*b ", str(a*b))101 a = pd.DataFrame([[1, 2], [3, np.nan, ], [5, 6]], columns=["a", "b"])102 b = pd.DataFrame([[1, 2, 3], [3, 4, 5], [5, 6, 7]], columns=["c", "b", "d"]) * 10103 self.print_tb(" new a is ", str(a))104 self.print_tb(" new b is ", str(b))105 self.print_tb(" a*b ", str(a*b))106 return_df = pd.DataFrame(107 [108 [np.nan, np.nan, 2],109 [3, np.nan, 3],110 [5, 6, np.nan],111 ],112 columns=["삼성", "현대", "SK"]113 )114 asset_on_df = pd.DataFrame(115 [116 [0, 1],117 [0, 1],118 [1, 0],119 ],120 columns=["삼성", "SK"]121 )122 return_df123 asset_on_df124 @clear_textbrowser_decorator125 def on_clicked_make_ana_data_btn(self):126 make_ana_data(self)127 """128 # using datareader129 # samsung_df = fdr.DataReader('005390', '2017-01-01', '2017-12-31')130 # self.print_tb("8", str(samsung_df))131 df_005930 = marcap_data('2021-01-21', code='005930')132 df_005930 = df_005930.assign(Amount=df_005930['Amount'].astype('int64'),133 Marcap=df_005930['Marcap'].astype('int64'))134 self.print_tb(" df_005930 ", str(df_005930))135 """136 @clear_textbrowser_decorator137 def on_clicked_load_data_btn(self):138 """139 데이터 로드140 """141 df = pd.read_csv("data/fin_statement_new.csv")142 self.print_tb("0", str(df))143 """144 데이터 정리145 """146 # 상장일 열 제거147 df = df.drop(["상장일"], axis=1)148 # rename 열149 df = df.rename(columns={150 "DPS(보통주, 현금+주식, 연간)": "DPS",151 "P/E(Adj., FY End)": "PER",152 "P/B(Adj., FY End)": "PBR",153 "P/S(Adj., FY End)": "PSR",154 })155 """156 정렬 및 데이터 분석157 """158 # 년도로 정렬하고 이름이 몇 개인지 카운트159 self.print_tb("1", str(df.groupby(['year'])['Name'].count()))160 # 이름으로 정렬하고 몇 년동안 있었는지 카운트161 self.print_tb("2", str(df.groupby(['Name'])['year'].count()))162 # code or name의 중복 체킹 방법1163 self.print_tb("3", str(df.groupby(['year'])['Name'].nunique().equals(df.groupby(['year'])['Code'].nunique())))164 # code or name의 중복 체킹 방법2165 self.print_tb("4", str(df.groupby(['year', 'Name'])['Code'].nunique()))166 self.print_tb("5", str(df.groupby(['year', 'Name'])['Code'].nunique().nunique()))167 # index를 df의 year로 하고 / column을 df의 Name / 값은 df의 수정주가로 설정168 yearly_price_df = df.pivot(index="year", columns="Name", values="수정주가")169 self.print_tb("6", str(yearly_price_df))170 # 한 해 수익률 구하기171 yearly_rtn_df = yearly_price_df.pct_change(fill_method=None).shift(-1)172 self.print_tb("7", str(yearly_rtn_df))173 # 상장폐지 종목 처리174 self.print_tb("8", str(yearly_price_df['AD모터스']))175 self.print_tb("9", str(yearly_price_df['AD모터스'].pct_change(fill_method=None).shift(-1)))176 # self.load_data_btn.setDisabled(True)177 def print_tb(self, print_log_name="0", msg=""):178 self.log_textBrowser.moveCursor(QtGui.QTextCursor.End)179 if print_log_name == "0":180 self.log_textBrowser.insertPlainText("\n" + msg)181 else:182 self.log_textBrowser.insertPlainText("***************" + print_log_name + " *************** : \n")183 self.log_textBrowser.insertPlainText("\n" + msg)184 self.log_textBrowser.insertPlainText("\n\n *************** " + print_log_name + " *************** - end : \n\n")185 QApplication.processEvents(QEventLoop.ExcludeUserInputEvents)186 def on_clicked_clear_tb_btn(self):187 self.log_textBrowser.clear()188app = QApplication(sys.argv)189mw = MainWindow()190mw.show()191app.exec_()

Full Screen

Full Screen

strategy1.py

Source:strategy1.py Github

copy

Full Screen

...10 def start(self):11 """12 Load data13 """14 self.parent.print_tb(" origin df", str(self.df))15 """16 Filter17 """18 market_cap_quantile_series = self.df.groupby("year")['시가총액'].quantile(.2)19 self.parent.print_tb(" 년도별 시가 총액 하위 20%", str(market_cap_quantile_series))20 filtered_df = self.df.join(market_cap_quantile_series, on="year", how="left", rsuffix="20%_quantile")21 filtered_df = filtered_df[filtered_df['시가총액'] <= filtered_df['시가총액20%_quantile']]22 self.parent.print_tb(" 시가 총액 하위 20%만 남기고 필터링", str(filtered_df))23 """24 Selector25 """26 # Selector - 127 filtered_df = filtered_df[filtered_df['PBR'] >= 0.2]28 self.parent.print_tb(" PBR 0.2 이상 필터링", str(filtered_df))29 # Selector - 230 smallest_pbr_series = filtered_df.groupby("year")['PBR'].nsmallest(15)31 self.parent.print_tb(" 년도별 하위 15개 필터링", str(smallest_pbr_series))32 # Selector - 333 # 시가 총액 하위 20% + PBR 0.2 이상 + 년도별 하위 15개의 index를 넘긴다34 selected_index = smallest_pbr_series.index.get_level_values(1)35 selector_df = filtered_df.loc[selected_index].pivot(36 index='year', columns="Name", values="PBR"37 )38 # 필터링된 데이터는 pbr이 들어가고 나머지는 nan가 들어간다39 self.parent.print_tb(" selector_df", str(selector_df))40 # pbr이 있을경우 매수했다고 가정해서 1로 처리 + pbr이 0인 데이터는 nan로 처리41 asset_on_df = selector_df.notna().astype(int).replace(0, np.nan)42 self.parent.print_tb(" asset_on_df", str(asset_on_df))43 selected_return_df = self.yearly_rtn_df * asset_on_df44 rtn_series, cum_rtn_series = plothelper.get_return_series(selected_return_df)...

Full Screen

Full Screen

dtest.py

Source:dtest.py Github

copy

Full Screen

...7 lumberjack()8except IndexError:9 exc_type, exc_value, exc_traceback = sys.exc_info()10 # print("*** print_tb:")11 # dtraceback.print_tb(exc_traceback, file=sys.stdout)12 print("*** print_tb verbose 1:")13 dtraceback.print_tb(exc_traceback, file=sys.stdout, verbosity=1)14 print("*** print_tb verbose 2:")15 dtraceback.print_tb(exc_traceback, file=sys.stdout, verbosity=2)...

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 Slash 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