def prepareDataBtnAction(self): ftypes = [('JavaScript Object Notation files', '*.json')] filePath = filedialog.askopenfilename(initialdir = ".\\files\\RAW files", title = "Select raw data file", filetypes=ftypes) if filePath: unprocessed_data = fh.rawJsonRW(filePath, 'r') root.configure(cursor='wait') root.grab_set() final_fields = ['id', 'name', 'fan_count', 'overall_star_rating', 'restaurant_services', 'category', 'restaurant_specialties', 'price_range', 'talking_about_count', 'checkins'] final_services = ["delivery", "reserve", "waiter"] reduced_data = fh.selectAndFill(final_fields, ['restaurant_services'], [final_services], unprocessed_data) self.dataset = fh.convertToDF(reduced_data) messagebox.showinfo('Message', 'Finished preparing data. Prepared {0} records.'.format(len(self.dataset))) self.enableButton(self.saveBtn, True) for child in self.statsFrame.winfo_children(): try: child.config(state='normal') except: continue root.grab_release() root.configure(cursor='arrow') else: print('cancelled')
def fetchDataBtnAction(self): queryObj = self.fetch_builder.get_object('qtermsTxt', root) selected_qterms = queryObj.get("1.0",'end-1c') self.qterms = selected_qterms.split(',') tokenObj = self.fetch_builder.get_object('tokenTxt', root) buttonObj = self.fetch_builder.get_object('fetchDBtn', root) self.token = tokenObj.get("1.0",'end-1c') buttonObj.configure(text='Fetching....') self.mainwindow.configure(cursor='wait') unprocessed_data = fh.fetchOnlineData(self.token, self.selectedFields, self.qterms) messagebox.showinfo('Message', 'Fetched {0} records.'.format(len(unprocessed_data))) filePath = filedialog.asksaveasfilename(initialdir = ".\\files\\RAW files", title = "Choose where to save the raw data file", filetypes=[("JavaScript Object Notation file","*.json*")]) if filePath: fh.rawJsonRW(filePath, 'w', unprocessed_data) # Dump raw data to json file messagebox.showinfo('Message', 'File saved successfully. Wrote {0} records.'.format(len(unprocessed_data))) self.mainwindow.configure(cursor='arrow') self.fetch_root.grab_release() #Enable underlaying frames self.fetch_root.destroy() else: print('cancelled')
def saveFileBtnAction(self): filePath = filedialog.asksaveasfilename(initialdir = ".\\files\\Processed files", title = "Choose where to save dataset file", filetypes=[("all files","*.*")]) if filePath: fileType = os.path.splitext(filePath)[1] fh.writeToFile(filePath, fileType[1:], self.dataset) messagebox.showinfo('Message', 'File saved successfully. Wrote {0} records.'.format(len(self.dataset))) else: print('cancelled')
def pcrOkBtnAction(self): selected_numeric1 = self.pcr_nums1ComboBox.get() selected_numeric2 = self.pcr_nums2ComboBox.get() if selected_numeric1: if selected_numeric2: self.pcr_root.grab_release() self.pcr_root.destroy() fh.relationship(selected_numeric2, selected_numeric1, self.dataset) else: messagebox.showerror('Message', 'Not all fields were selected') else: messagebox.showerror('Message', 'Not all fields were selected')
def anovaOkBtnAction(self): selected_category = self.anv_catsComboBox.get() selected_numeric = self.anv_numsComboBox.get() if selected_category: if selected_numeric: self.anv_root.grab_release() self.anv_root.destroy() result = fh.oneway_anova(selected_numeric, selected_category, self.dataset) self.console.configure(state='normal') self.console.delete(1.0, "end") self.console.insert("end", "Results of One-Way ANOVA Test-----------------------------------------+\n\n") self.console.insert("end", result) self.console.insert("end", "\n\n+-----------------------------------------------------------------+\n") self.console.configure(state='disable') else: messagebox.showerror('Message', 'No DV was selected') else: messagebox.showerror('Message', 'No IV was selected')
def independentTOkBtnAction(self): selected_category = self.ind_catsComboBox.get() selected_numeric = self.ind_numsComboBox.get() if selected_category: if selected_numeric: self.ind_root.grab_release() self.ind_root.destroy() result = fh.independent_ttest(selected_numeric, selected_category, self.dataset) self.console.configure(state='normal') self.console.delete(1.0, "end") self.console.insert("end", "Results of Independent samples T-Test-------------------------------+\n\n") self.console.insert("end", result) self.console.insert("end", "\n\n+-----------------------------------------------------------------+\n") self.console.configure(state='disable') else: messagebox.showerror('Message', 'No DV was selected') else: messagebox.showerror('Message', 'No IV was selected')
def loadFileBtnAction(self): ftypes = [ ('Comma-Separated Values files', '*.csv'), ('Excel Microsoft Office Open XML Format Spreadsheet files', '*.xlsx'), ('JavaScript Object Notation files', '*.json') ] filePath = filedialog.askopenfilename(initialdir = ".\\files\\Processed files", title = "Select dataset file", filetypes=ftypes) if filePath: fileType = os.path.splitext(filePath)[1] self.dataset = fh.readFile(filePath, fileType[1:]) messagebox.showinfo('Message', 'Dataset read successfully. Read {0} records.'.format(len(self.dataset))) self.dataset = self.dataset.set_index('id') self.enableButton(self.saveBtn, True) for child in self.statsFrame.winfo_children(): try: child.config(state='normal') except: continue else: print('cancelled')
def regressionOkBtnAction(self): selected_iv1 = self.reg_iv1ComboBox.get() selected_iv2 = self.reg_iv2ComboBox.get() selected_dv = self.reg_dvComboBox.get() if selected_iv1: if selected_iv2: if selected_dv: self.reg_root.grab_release() self.reg_root.destroy() result = fh.liner_regression(selected_dv, selected_iv1, selected_iv2, self.dataset) self.console.configure(state='normal') self.console.delete(1.0, "end") self.console.insert("end", "Results of linear Regression Test-------------------------------------+\n\n") self.console.insert("end", result) self.console.insert("end", "\n\n+-----------------------------------------------------------------+\n") self.console.configure(state='disable') else: messagebox.showerror('Message', 'No DV was selected') else: messagebox.showerror('Message', 'Not enough IVs ware selected') else: messagebox.showerror('Message', 'Not enough IVs ware selected')
def anovaTwoOkBtnAction(self): selected_category1 = self.anv2_cats1ComboBox.get() selected_category2 = self.anv2_cats2ComboBox.get() selected_numeric = self.anv2_numsComboBox.get() if selected_category1: if selected_category2: if selected_numeric: self.anv2_root.grab_release() self.anv2_root.destroy() result = fh.twoway_anova(selected_numeric, selected_category1, selected_category2, self.dataset) self.console.configure(state='normal') self.console.delete(1.0, "end") self.console.insert("end", "Results of Two-Way ANOVA Test-----------------------------------------+\n\n") self.console.insert("end", result) self.console.insert("end", "\n\n+-----------------------------------------------------------------+\n") self.console.configure(state='disable') else: messagebox.showerror('Message', 'No DV was selected') else: messagebox.showerror('Message', 'Not enough IVs ware selected') else: messagebox.showerror('Message', 'Not enough IVs ware selected')