def affiche_data(self, data, v): y1 = self.y // 20 y2 = self.y // 14 y3 = self.y - y1 - y2 x3 = self.x // 5 if v == 'train': self.hide_show('train', '0') self.btrain_cleaning.grid() f = Frame(self.root) f.grid(row=0, column=0) pt = Table(self.centre_frame1, dataframe=data, height=y3 - y2, width=3 * x3 - 30) pt.show() if v == 'test': self.hide_show('test', '1') self.btrain_cleaning.grid_forget() self.btest_cleaning.grid() f = Frame(self.root) f.grid(row=0, column=0) pt = Table(self.centre_frame1, dataframe=data, height=y3 - y2, width=3 * x3 - 30) pt.show()
def stemming(self, v): y1 = self.y // 20 y2 = self.y // 14 y3 = self.y - y1 - y2 x3 = self.x // 5 if v == 'train': self.data1['statement'] = go_nettoyage.stem(self.statement1) self.pt1 = Table(self.centre_frame1, dataframe=self.data1, height=y3 - y2, width=3 * x3 - 30) self.pt1.show() #self.bidf_tf1.grid(row=2, column=0, sticky=S) if v == 'test': self.data2['statement'] = go_nettoyage.stem(self.statement2) # self.data2['statement']=go_nettoyage.stem(self.statement2) self.pt2 = Table(self.centre_frame1, dataframe=self.data2, height=y3 - y2, width=3 * x3 - 30) self.pt2.show()
def affiche_data(self, data, v): y1 = self.y // 20 y2 = self.y // 14 y3 = self.y - y1 - y2 x3 = self.x // 5 self.centre_frame1 = Frame(self.root) self.centre_frame1.grid(row=3, column=0, sticky=N) if v == 'train': self.pt1 = Table(self.centre_frame1, dataframe=data, height=y3 - y2, width=3 * x3 - 30) self.pt1.show() if v == 'test': f = Frame(self.root) f.grid(row=0, column=0) self.pt2 = Table(self.centre_frame1, dataframe=data, height=y3 - y2, width=3 * x3 - 30) self.pt2.show()
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) lable = tk.Label(self, text="Apache Server", font=LARGE_FONT) lable.grid(row=0, column=1) button1 = tk.Button(self, text="Back", command=lambda: controller.show_frame(StartPage)) button1.grid(row=3, column=1) # Object of Apache Class print("-----------PageApapche-------") obj_ap = Apache_Server() apache_df = obj_ap.apache_analysis() print(apache_df) lb1 = tk.Label(self, text="Sucessfull Attempts", font=MID_FONT) lb1.grid(row=1, column=0) f = tk.Frame(self) f.grid(row=2, column=0) pt_apache_active = Table(f, dataframe=apache_df, showstatusbar=True, showtoolbar=False) pt_apache_active.show() apache_df_fail = obj_ap.apache_failed() lb2 = tk.Label(self, text="Failed Attempts", font=MID_FONT) lb2.grid(row=1, column=2) g = tk.Frame(self) g.grid(row=2, column=2) pt_apache_fail = Table(g, dataframe=apache_df_fail, showstatusbar=True, showtoolbar=False) pt_apache_fail.show()
def company_ratios(Name): url = ('https://financialmodelingprep.com/api/v3/financial-ratios/' + Name + '') res = requests.get(url) data = res.json() #print(data['ratios'][0]) valuation = data['ratios'][0]['investmentValuationRatios'] profitabilityIndicatorRatios = data['ratios'][0][ 'profitabilityIndicatorRatios'] operatingPerformanceRatios = data['ratios'][0][ 'operatingPerformanceRatios'] liquidityMeasurementRatios = data['ratios'][0][ 'liquidityMeasurementRatios'] debtRatios = data['ratios'][0]['debtRatios'] cashFlowIndicatorRatios = data['ratios'][0]['cashFlowIndicatorRatios'] pt = Table(mighty5) valuation = pd.DataFrame(list(valuation.items()), columns=['Ratio', Name]) profitabilityIndicatorRatios = pd.DataFrame(list( profitabilityIndicatorRatios.items()), columns=['Ratio', Name]) operatingPerformanceRatios = pd.DataFrame(list( operatingPerformanceRatios.items()), columns=['Ratio', Name]) liquidityMeasurementRatios = pd.DataFrame(list( liquidityMeasurementRatios.items()), columns=['Ratio', Name]) debtRatios = pd.DataFrame(list(debtRatios.items()), columns=['Ratio', Name]) cashFlowIndicatorRatios = pd.DataFrame(list( cashFlowIndicatorRatios.items()), columns=['Ratio', Name]) fr = [ valuation, profitabilityIndicatorRatios, operatingPerformanceRatios, liquidityMeasurementRatios, debtRatios, cashFlowIndicatorRatios ] cfr = pd.concat(fr) df = pt.model.df table = pt = Table(mighty5, dataframe=cfr, showtoolbar=True, showstatusbar=False) table.show()
def smmm(u): #f.grid(row=15,column=0,sticky=W,ipadx=600,ipady=17) df = TableModel.getSampleData() pt = Table(leftFrame2,dataframe=u,showtoolbar=True, showstatusbar=True) pt.grid(row=15,column=0,sticky=W,ipadx=345,ipady=17) pt.show()
def load_click(): init_dir = "" if (selected_sport.get() == 1): init_dir = "/home/pete/Documents/dk_player_exports/" elif (selected_sport.get() == 2): init_dir = "/home/pete/Documents/nhl/dk_player_exports/" else: sys.exit("INVALID SPORT SELECTED") player_file = filedialog.askopenfilename(initialdir=init_dir, title='Select Projections') print(player_file) load_label.configure(text=player_file, width=0) save_button.state(['disabled']) optimize_button.state(['!disabled']) try: global ffa_player_projections ffa_player_projections = pd.read_csv(player_file) LoadOptimizer(player_file) player_value = [] AddValueColumn(player_value) ffa_player_projections = ffa_player_projections.assign( Value=player_value) except: sys.exit("Invalid file type") global table table = Table(middle_left_frame, dataframe=ffa_player_projections) table.grid(column=0, row=0, rowspan=2) table.show() add_lock_button.state(['!disabled']) add_exclude_button.state(['!disabled']) remove_lock_button.state(['!disabled']) remove_exclude_button.state(['!disabled'])
def conv_to_xls(self): try: empsal_df = pd.read_csv('empsal.csv') empsal_df = empsal_df.set_index('empno') print(empsal_df) # Next - Pandas DF to Excel file on disk if (len(empsal_df) == 0): msg.showinfo('No Rows Selected', 'CSV has no rows') else: with pd.ExcelWriter( 'empsal.xls' ) as writer: # saves in the current directory empsal_df.to_excel(writer, 'EmpsalSheet') writer.save() msg.showinfo('Excel file ceated', 'Excel File created') self.f = Frame(root, height=200, width=300) self.f.pack(fill=BOTH, expand=1) self.table = Table(self.f, dataframe=empsal_df, read_only=True) self.table.show() except FileNotFoundError as e: msg.showerror('Error in opening file', e)
def affi_test(self,center_frame): y1 = self.y // 20 y2 = self.y // 14 y3 = self.y - y1 - y2 x3 = self.x // 5 pt = Table(center_frame, dataframe=self.df, height=y3 - y2, width=3 * x3 - 30) pt.show()
def __init__(self, parent=None): self.parent = parent Frame.__init__(self) self.main = self.master self.main.geometry('600x400+200+100') self.main.title('Table app') f = Frame(self.main) f.pack(fill=BOTH, expand=1) modelo = joblib.load("modelo_sna.pkl") dft = pd.read_csv("sna_churn.csv") df = dft.drop('NUMERO', axis=1) pred0 = [] pred1 = [] for y0, y1 in modelo.predict_proba(df): pred0.append(y0) pred1.append(y1) df['PROB_NO_CHURN'] = pred0 df['PROB_CHURN'] = pred1 df['ID'] = dft['NUMERO'] result = df[['ID', 'PROB_NO_CHURN', 'PROB_CHURN']] self.table = pt = Table(f, dataframe=result, showtoolbar=True, showstatusbar=True) pt.show() return
def get_bill(self): df = pd.read_csv("product_info.csv") df1 = pd.read_csv( r"C:\Users\Siddarth\Desktop\projects\MART\customer_uploads\store\Mart List.csv" ) df3 = pd.merge(df, df1, how='inner') df3['NET AMOUNT'] = (df3.QUANTITY * df3.MRP) # print(tabulate(df, headers='keys', tablefmt='presto')) perproduct = list(df3['NET AMOUNT']) total = 0 for ele in range(0, len(perproduct)): total = total + perproduct[ele] print(total) str_io = io.StringIO() df3.to_html(bold_rows=True, justify='center', border=5, buf=str_io, classes='table table-striped') html_str = str_io.getvalue() cart = Tk() cart.title("YOUR CART") cartdisplay = Frame(cart) cartdisplay.pack(fill='both', expand=True) pt = Table(cartdisplay, dataframe=df3) self.Show.configure(command=pt.show) self.Show.place(relx=0.3, rely=0.7, anchor=CENTER) return html_str, total
def retrievePassword(root, userSecret): root.destroy() hoje = Tk() hoje.geometry("480x300") hoje.title('SmartLocker') FILENAME = Image.open('photo.png') tk_img = ImageTk.PhotoImage(FILENAME) frame1 = tk.Frame(hoje, bg='black') frame1.place(relwidth=1.0, relheight=1.0) frame1.place(relwidth=1.0, relheight=1.0) labetse2 = Label(frame1, image=tk_img) labetse2.pack() labetset = Label(frame1, image=tk_img) #labetset.grid(row=0, column=0) labetset.pack() labetset.place(relwidth=1.0, relheight=0.6) frameText = Label(labetset, text="Take a look on what info we have!", bg='black', fg='white', font=('Courier', 17)) #frameText.grid(row=2, columnspan=3) frameText.place(x=15, y=280) #userSecret.showServices() toolbar = tk.Frame(labetset) pt = Table(labetset, width=480, height=150) button = tk.Button(frame1, text="Quit", font='Courier', fg='red', background='blue', highlightbackground='green', command=quit) button.place(x=220, y=250) buttonSwitch = tk.Button(frame1, text="Add New Account", font='Courier', fg='red', background='blue', highlightbackground='green', command=lambda: frameAddPassword(hoje)) buttonSwitch.place(x=280, y=250) pt.importCSV(filename='password.csv') pt.show() pt.setColumnColors(cols=2, clr='red') #button.place(x=100, y =100) hoje.mainloop()
def equal_rebalancing(self): self.invest_amount_calculation() self.equal_df = pd.DataFrame() number_of_stocks = len(self.new_df.index) invest_amount_per_stock = self.invest_amount/number_of_stocks for i, price in enumerate(self.new_df['Current Price']): temp_series = pd.Series([invest_amount_per_stock/price], index=['Equal Rebalance']) temp_series = self.new_df.iloc[i].append(temp_series) self.equal_df = self.equal_df.append(temp_series, ignore_index=True) self.equal_df = self.equal_df[['Symbol', 'Description', 'Sector', 'Quantity', 'Equal Rebalance', 'Cost Basis Per Share', 'Market Cap', 'Current Price', 'P/E Ratio(PER)', 'P/B Ratio(PBR)']] # self.pt.clearData() self.pt = Table(self.display, dataframe=self.equal_df, showtoolbar=False, showstatusbar=False, editable=False, enable_menus=False) options = config.load_options() options = {'rowselectedcolor':None} config.apply_options(options, self.pt) self.pt.show() # Add color to indicate 'add' or 'sub' quantity to user. Green color for add. Red color for Sub. add_mask = self.equal_df['Quantity'] < self.equal_df['Equal Rebalance'] self.pt.setColorByMask('Equal Rebalance', add_mask, '#7FFF00') sub_mask = self.equal_df['Quantity'] > self.equal_df['Equal Rebalance'] self.pt.setColorByMask('Equal Rebalance', sub_mask, '#FF6EB4') # self.pt.redraw() self.pt.autoResizeColumns()
def refresh_df(self, mianfram, project_detail): try: self.save_project() except Exception as e: tk.messagebox.showwarning('错误', e) project_detail['状态'] = project_detail.apply( lambda x: 'Good' if x['模块类型'] == 'project' else self.refresh_check(x['保存地址']), axis=1) # project_detail = project_detail[['模块类型', '模块名字', '引用模块', '保存地址', '状态','创建时间']] f = Frame(mianfram) f.grid(row=1, column=0, rowspan=1, columnspan=5, sticky=(E, W)) screen_width = f.winfo_screenwidth() * 0.8 screen_height = f.winfo_screenheight() * 0.8 self.table = self.ptm = Table(f, dataframe=project_detail, height=screen_height, width=screen_width) ##Table本身为tkinter的class self.table.show() self.table.grid() self.table.bind("<Button-2>", self.right_click_menu) ##使用bind原因为保证相应的事件发生后调用相应的函数 self.table.bind("<Button-3>", self.right_click_menu) self.table.bind("<Double-Button-1>", self.right_click_menu) self.table.bind("<Double-Button-2>", self.right_click_menu) self.table.bind("<Double-Button-3>", self.right_click_menu)
def afficher_idf(self,root): centre_frame1 = Frame(root, bg='white', width=630, height=700) centre_frame1.grid(row=3, column=0, sticky=N) centre_frame1.grid_propagate(0) self.data = pd.DataFrame(self.tf_idf2, columns=list(self.tf_idf2[0].keys())) pt = Table(centre_frame1, dataframe=self.data, height=self.h, width=self.w) pt.show()
def customPandasTable(self, parent): def set_order(cols_order): # fix kolejnosci kolumn x = [] for i in cols_order: x.append(list(df.columns).index(i)) return x field = tk.LabelFrame(parent, bd=0, bg="#515E5A") field.pack(fill=tk.BOTH, expand=1) df = pd.DataFrame(self.dataSet) # wczytanie danych df = df.transpose() # transpozycja danych ( zamiana wierszy z kolumnami ) if df.keys().__len__() is not 0: df = df[df.columns[set_order(list(self.dataSet[str(0)].keys()))]] if 'Result' in df.columns: df['AssignmentID'] = df['AssignmentID'].astype(int) if 'ID' in df.columns: df['ID'] = df['ID'].astype(int) self.table = Table(field, dataframe=df, showtoolbar=False, showstatusbar=False) self.table.show() return field
def display_excel(self): try: if (os.path.exists('E:\project5\stock_price.xls')): stock_price_df = pd.read_excel('E:\project5\stock_price.xls') else: msg.showerror('Excel file not found', 'stock price excel file not found') if (len(stock_price_df) == 0): msg.showinfo('No records in Excel file', 'No records in excel file') else: msg.showinfo('Pandas DF created', 'Pandas DF created') self.f = Frame(root, height=200, width=300) self.f.pack(fill=BOTH, expand=1) self.table = Table(self.f, dataframe=stock_price_df, read_only=True) self.table.show() except FileNotFoundError as e: msg.showerror('excel file not found', 'stock price excel not found')
def PandasTable(self, df): self.table = pt = Table(self.tableFrame, dataframe=df, showtoolbar=False, showstatusbar=False) pt.show()
def update_df(self): try: empsal_df = pd.read_excel("Empsal.xlsx", index_col='empno', parse_dates=['dob']) def age_cal(dob): today = date.today() Age = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) return Age empsal_df['Age'] = empsal_df['dob'].apply(age_cal) empsal_df['conv'] = 0.1 * empsal_df['salary'] empsal_df['total'] = empsal_df['salary'] + empsal_df[ 'hra'] + empsal_df['conv'] print(empsal_df.head(10)) empsal_df.to_csv('empsalupdated.csv') if (len(empsal_df) == 0): msg.showinfo('Warning', 'No records') else: msg.showinfo('Message', 'Pandas df created') self.f = Frame(root, height=300, width=800) self.f.pack(fill=BOTH, expand=1) self.table = Table(self.f, dataframe=empsal_df, read_only=True) self.table.show() except FileNotFoundError as e: msg.showerror('Error in Finding File', e)
def display(self, parent): data = parent.prop_currentData #parent.getData() report = Table(self, dataframe=data, showstatusbar=True, editable=False) # 建立table report.showIndex() # 加入此行才能顯示index report.show() #95
def __init__(self, parent, predictions, years): super().__init__(parent) pred = {} i = 0 for p in predictions: pred[years[i]] = p i += 1 self.df = pd.DataFrame(pred) self.frame = Frame(self, relief=RAISED, borderwidth=1) self.table = Table(self.frame, dataframe=self.df, showtoolbar=True, showstatusbar=True) # График # self.graph = plt.scatter(years, predictions, c='green') self.f = Figure(figsize=(5, 4), dpi=100) self.a = self.f.add_subplot(111) years_str = [str(y) for y in years] self.a.plot(years_str, predictions) # a tk.DrawingArea self.canvas = FigureCanvasTkAgg(self.f, master=self) self.parent = parent self.mycompany = company.Company() self.initUI() self.style = Style() print(self.style.theme_names()) self.style.theme_use('winnative') self.closeButton = Button(self, text="Закрыть", command=self.quit) self.closeButton.pack(side=RIGHT, padx=5, pady=5)
def gui_show_database_content(database_obj): """GUI shows the remaining questions in selected_database.""" display_top = Toplevel() display_top.title("All questions in Database") tables_list = pd.DataFrame(r.to_dict() for r in database_obj) tables_list.rename(columns={ 0: "ID", 1: "Question", 2: "Answer1", 3: "Answer2", 4: "Answer3", 5: "Answer4", 6: "Answer5", 7: "1 if Correct", 8: "1 if Correct", 9: "1 if Correct", 10: "1 if Correct", 11: "1 if Correct" }, inplace=True) my_frame = Frame(display_top) my_frame.grid(row=5, column=0, columnspan=10) display_table = Table(parent=my_frame, dataframe=tables_list, showtoolbar=True) display_table.show()
def create_widgets(self): # Create buttons to manage the DB. self.toolbar = tk.Frame(self) self.toolbar.grid(row=0, column=0, padx=12, pady=3, sticky="NSEW") for col in range(12): self.toolbar.columnconfigure(index=col, weight=1) self.save_button = tk.Button( self.toolbar, text="Save Data To DB", command=self.save_to_db) self.export_button = tk.Button( self.toolbar, text="Export Data to File", command=self.export_data) self.import_button = tk.Button( self.toolbar, text="Import Data from CSV", command=self.import_csv) self.refresh_button = tk.Button( self.toolbar, text="Refresh Data from DB", command=self.refresh_table_data) self.save_button.grid(row=0, column=12) self.export_button.grid(row=0, column=11) self.import_button.grid(row=0, column=10) self.refresh_button.grid(row=0, column=9) self.table_container = tk.Frame(self) self.table_container.grid(row=1, column=0, sticky="NSEW") # Create table to display data data_df = DataStore.data self.data_table = Table(self.table_container, dataframe=data_df) self.data_table.autoResizeColumns() self.data_table.show()
def get_subsitute(): name = t1.get() # Get the index of the item that matches the title idx = indices[name] # Get the pairwsie similarity scores of all items with that items sim_scores = list(enumerate(cosine_sim[idx])) # Sort the items based on the similarity scores def get_key(elem): return elem[1] sim_scores.sort(key=get_key, reverse=True) # Get the scores of the 10 most similar items sim_scores = sim_scores[1:11] # Get the items indices item_indices = [i[0] for i in sim_scores] # Return the top 10 most similar items #print (type( df_new['name'].iloc[item_indices])) df = ((df_new.iloc[item_indices].sort_values(by='price'))) pt = Table(frame, dataframe=df) pt.place(x=0, y=300) pt.show()
def create_table(field, db): import tkinter as tk from pandastable import Table from pandas import read_sql # initialize SQL query query = """SELECT DISTINCT """ + field.get() + """ FROM pompei.scarpa;""" # read-in data as pandas dataframe df = read_sql(query, db) # initialize a window and table frame window = tk.Tk() table_frame = tk.Frame(window) # format table window window_width = window.winfo_reqwidth() window_height = window.winfo_reqheight() position_right = int(window.winfo_screenwidth() / 3 - window_width / 3) position_down = int(window.winfo_screenheight() / 3 - window_height / 3) window.geometry("+{}+{}".format(position_right, position_down)) window.title('Risultati di ricerca') # initialize table table = Table(table_frame, dataframe=df) # pack the the table frame table_frame.pack(fill='both', expand=1) # display the table table.show()
def __init__(self, parent=None): self.parent = parent Frame.__init__(self) self.main = self.master self.main.geometry('1680x1024+200+100') self.main.title('Table app') f = Frame(self.main) f.pack(fill=BOTH, expand=1) self.df = None #self.df = TableModel.getSampleData() self.table = pt = Table(f, dataframe=self.df, showtoolbar=True, showstatusbar=True) self.locColName = 'RLocation' try: print("loading pickle") pt.model.load("temp_model.pickle") except IOError: print("Couldn't find picke. Will load test.csv") pt.importCSV('test.csv') pt.model.addColumn(self.locColName, 'object') pt.model.moveColumn(pt.model.df.columns.get_loc(self.locColName), 1) pt.bind('<Control-Button-1>', self.leftClicked) pt.bind('<Control-l>', self.learnModel) pt.bind('<Control-o>', self.writeCSV) pt.show() return
def drawTable(): df = main.predict('bundes', 15) self.table = pt = Table(frame1, dataframe=df, showtoolbar=False, showstatusbar=True) pt.show()
def __init__(self, master): toplevel = Toplevel() toplevel.title("Table") frame = Frame(toplevel) frame.grid(row=0, column=0) table = Table(frame, dataframe=sources) table.show()
def __init__(self, parent=None): self.parent = parent Frame.__init__(self) self.main = self.master self.main.geometry('600x400+200+100') self.main.title('Table app') f = Frame(self.main) f.pack(fill=BOTH, expand=1) df = TableModel.getSampleData() self.table = pt = Table(f, dataframe=df, showtoolbar=True, showstatusbar=True) pt.show() return
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) lable = tk.Label(self, text="Firewall", font=LARGE_FONT) lable.pack(pady=10, padx=10) objPF = Firewall() dfPF = objPF.failed_attempt() print("-------------Screen UI ---", dfPF) lable1 = tk.Label(self, text="Firewall Unauthorised Access", font=LARGE_FONT) lable1.pack(pady=20, padx=10) f = tk.Frame(self) f.pack(pady=12, padx=5, expand=False) pt = Table(f, dataframe=dfPF, showstatusbar=True, showtoolbar=False) pt.show() button2 = tk.Button( self, text="Traffic", command=lambda: controller.show_frame(PageFirewallActiveUser)) button2.pack() button1 = tk.Button(self, text="Back", command=lambda: controller.show_frame(StartPage)) button1.pack()