Beispiel #1
0
    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 EstadisticosPregRes():
	global root
	#screenEA.withdraw()
	root = Toplevel(screen)
	root.title('PandasTable Example')
	root.geometry('900x400')

	global dataPreg
	dataPreg = pd.DataFrame(list(col_pregunta_respuesta.find()))
	dataPreg = pd.DataFrame(dataPreg)
	del dataPreg['_id']
	print(dataPreg.isnull().sum())

	dataPreg = dataPreg[dataPreg['calificacion'].notna()]

	frame = tk.Frame(root)
	frame.pack(fill='both', expand=True)
	pt = Table(frame, dataframe=dataPreg)
	pt.show()
	buttonCali = tk.Button(root, text='Preguntas\nPor calificación',bd=7, font = ("monaco",10,"bold"),padx=4,pady=4,fg="#263b54",  command = GraficaPreg_Calif,activeforeground="#1c2e44")
	buttonCali.place(x=30,y=342)
	buttonUsu = tk.Button(root, text='NPQRS\nPor Usuario',bd=7, font = ("monaco",10,"bold"),padx=4,pady=4,fg="#263b54",  command = GraficaPreg_Usu,activeforeground="#1c2e44")
	buttonUsu.pack()
	buttonEs = tk.Button(root, text='Frecuencia\nCalificación',bd=7, font = ("monaco",10,"bold"),padx=4,pady=4,fg="#263b54",  command = GraficaPreg_FrecEs,activeforeground="#1c2e44")
	buttonEs.place(x=720,y=342)
    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()
Beispiel #4
0
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()
Beispiel #5
0
class Pairings(tk.Toplevel):
    def __init__(self, master) -> None:
        super().__init__(master=master)
        self.wm_title(f"Pairings for Round {master.tnmt.round}")
        self.setup_menu()
        self.chart = tk.Frame(master=self)
        self.chart.pack()
        self.table = Table(self.chart,
                           dataframe=master.tnmt.pair(),
                           showstatusbar=True,
                           showtoolbar=True)
        self.table.show()

    def setup_menu(self):
        self.menu = tk.Menu(self)
        result_menu = tk.Menu(self.menu, tearoff=0)
        result_menu.add_command(label="Finalize", command=self.update_results)
        self.menu.add_cascade(label='Results', menu=result_menu)
        self.config(menu=self.menu)

    def update_results(self, event=None):
        results = ([float(i) for i in self.table.model.df["WResult"].tolist()])
        self.master.tnmt.record_results(results)
        self.master.update_standings()
        self.destroy()
def get_stats_for_var(
    dataframe, column: str
):  # displays descriptive statistics for a single column in new window
    new_dataframe = ((dataframe.loc[:, [column]]).describe())
    new_dataframe.index = [
        "count", "mean", "standard deviation", "minimum", "25% quartile",
        "median", "75% quartile", "max"
    ]
    root = tk.Tk()
    root.title(f"descriptive statistics for {column}")

    frame1 = tk.Frame(root)
    frame1.pack(side="top")
    frame2 = tk.Frame(root)
    frame2.pack(side="bottom")

    tk.Label(
        frame1,
        text=
        "1: count, 2: mean, 3: standard deviation, 4: minimum, 5: 25% quartile, "
        "6: median, 7: 75% quartile, 8: max").pack()

    table = Table(frame2, dataframe=new_dataframe, width=300, height=200)
    table.show()

    root.mainloop()
Beispiel #7
0
    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()
Beispiel #8
0
class TableView(tk.Frame):
    def __init__(self, master, dataframe):
        super().__init__(master)
        master.geometry("350x230")
        self.pack(fill=tk.BOTH, expand=True)
        self._df = dataframe
        self.df = self._df.copy()

        self.create_widget()

    def create_widget(self):
        self.bt = tk.Button(self, text="Show Table", command=self.show_table)
        self.bt.pack(fill=tk.BOTH, expand=True)

    def show_table(self):
        self.tbl_window = tk.Toplevel(self.master)
        frame = tk.Frame(self.tbl_window)
        frame.pack(fill=tk.BOTH, expand=True)

        self.tbl = Table(frame, dataframe=self.df)
        self.tbl.showIndex()
        self.tbl.show()

        frame_reset = tk.Frame(self.tbl_window)
        frame_reset.pack(fill=tk.BOTH, expand=True)
        btn = tk.Button(frame_reset,
                        text="Reset DataFrame",
                        command=self.reset_df)
        btn.pack()

    def reset_df(self):
        if messagebox.askyesno("Confirmation", "Do you really reset?"):
            self.df = self._df.copy()
            self.tbl_window.destroy()
            self.show_table()
def get_stats(dataframe):
    # creates a new tkinter window (using the pandastable module)
    # with all the pandas descriptive statistics for the dataframe
    root = tk.Tk()

    frame1 = tk.Frame(root)
    frame1.pack(side="top")
    frame2 = tk.Frame(root)
    frame2.pack(side="bottom")

    root.title(f"Stats table for {dataframe.name}")

    tk.Label(
        frame1,
        text=
        "1: count, 2: mean, 3: standard deviation, 4: minimum, 5: 25% quartile, "
        "6: median, 7: 75% quartile, 8: max").pack()
    # row indexes can't be changed in pandastable, so we need to make a tkinter Label to display this information

    table = Table(frame2,
                  dataframe=dataframe.describe(),
                  width=750,
                  height=200)
    table.show()

    root.mainloop()
 def conv_to_df(self):
     empsal_df = pd.read_csv("empsal.csv")
     #empsal_df.set_index('empno',inplace=True)
     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()
Beispiel #11
0
    def clean_text(self, v):
        if v == 'data1':
            self.data['statement'] = self.data["statement"].apply(
                lambda x: " ".join(word.lower() for word in x.split()))

            self.data['statement'] = self.data["statement"].str.replace(
                r"\W", " ")
            self.statement = list(self.data["statement"])
            self.statement = go_nettoyage.replace1(self.statement)
            y1 = self.y // 20
            y2 = self.y // 14
            y3 = self.y - y1 - y2
            x3 = self.x // 5

            pt = Table(self.centre_frame1,
                       dataframe=self.data,
                       height=y3 - y2,
                       width=3 * x3 - 30)
            pt.show()
            self.btext_steming.grid(row=1, column=0)
        if v == 'data2':

            self.data2['statement'] = self.data2["statement"].apply(
                lambda x: " ".join(word.lower() for word in x.split()))

            self.data2['statement'] = self.data2["statement"].str.replace(
                r"\W", " ")
            self.statement2 = list(self.data2["statement"])
            self.statement2 = go_nettoyage.replace1(self.statement2)
            self.btext_steming.grid(row=1, column=0)
    def print_protected_amino_acid_and_not(self, type):

        '''Check if ico file exist'''
        if self.check_if_ico_exist() == False:
            return f'"logo.ico" file doesnt exist. File has to be added to the directory;{self.ico_path()}'

        else:

            if type == "protected":
                amino = self.protectedamino
                title = "Protected Amino Acid"
            if type == "notprotected":
                amino = self.notprotectedamino
                title = "Amino Acid"
            if type == "endings":
                amino = self.endings
                title = "Terminus"
            root = tk.Tk()
            root.title(f'PeptideMassCalculator - {title}')
            root.iconbitmap(self.ico_path())
            frame = tk.Frame(root)
            frame.pack(fill='both', expand=True)
            datatable = Table(frame, dataframe=amino, showstatusbar=True)
            datatable.show()
            root.mainloop()
Beispiel #13
0
    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)
Beispiel #14
0
 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()
Beispiel #15
0
    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()
Beispiel #16
0
    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)
class create_df:
    def __init__(self, root):
        self.f = Frame(root, height=350, width=500)
        self.f.pack()

        self.message_label = Label(self.f,
                                   text='ADD NEW COLUMN IN  PANDAS DF',
                                   font=('Arial', 14))

        self.confirm_button = Button(self.f,
                                     text='Convert',
                                     font=('Arial', 14),
                                     bg='Orange',
                                     fg='Black',
                                     command=self.add_col)
        self.exit_button = Button(self.f,
                                  text='Exit',
                                  font=('Arial', 14),
                                  bg='Yellow',
                                  fg='Black',
                                  command=root.destroy)

        self.message_label.grid(row=1, column=0)
        self.confirm_button.grid(row=2, column=0)
        self.exit_button.grid(row=2, column=2)

    def add_col(self):
        df = pd.read_csv('empsal.csv')
        df['conv'] = (df.salary * 10) // 100
        df['total'] = df.salary + df.hra + df.conv
        self.f = Frame(root, height=200, width=300)
        self.f.pack(fill=BOTH, expand=1)
        self.table = Table(self.f, dataframe=df, read_only=True)
        self.table.show()
Beispiel #18
0
 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()
Beispiel #19
0
 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()
Beispiel #20
0
 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()
Beispiel #21
0
    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 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
Beispiel #23
0
 def __init__(self,
              parent=None,
              main_window=None,
              model=None,
              dataframe=None,
              width=None,
              height=None,
              rows=20,
              cols=5,
              showtoolbar=False,
              showstatusbar=False,
              editable=False,
              enable_menus=True,
              **kwargs):
     Table.__init__(self,
                    parent=parent,
                    model=model,
                    dataframe=dataframe,
                    width=width,
                    height=height,
                    rows=rows,
                    cols=cols,
                    showtoolbar=showtoolbar,
                    showstatusbar=showstatusbar,
                    editable=editable,
                    enable_menus=enable_menus,
                    **kwargs)
     self.main_window = main_window
Beispiel #24
0
    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')
Beispiel #25
0
    def create_widgets(self):
        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="Store in vault", command=self.save_to_db)
        self.export_button = tk.Button(
            self.toolbar, text="Export File", command=self.export_data)
        self.import_button = tk.Button(
            self.toolbar, text="Import CSV", command=self.import_csv)
        self.refresh_button = tk.Button(
            self.toolbar, text="Refresh 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 = tk.Frame(self) self.table_container.grid(row=1, column=0, sticky="")
        
        data_df = Vault.data

        self.data_table = Table(self.table_container, dataframe=data_df)
        self.data_table.autoResizeColumns()
        self.data_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()
Beispiel #27
0
class updt_df:
    def __init__(self, root):
        self.f = Frame(root, height=500, width=500)
        self.f.pack()

        self.message_label = Label(self.f,
                                   text='Display Updated Dataframe',
                                   font=('Roman', 24, 'bold'),
                                   fg='navy blue')
        self.confirm_button = Button(self.f,
                                     text='Display',
                                     font=('Arial', 14),
                                     bg='light green',
                                     fg='White',
                                     command=self.update_df,
                                     activeforeground='green')
        self.exit_button = Button(self.f,
                                  text='Exit',
                                  font=('Arial', 14),
                                  bg='pink',
                                  fg='White',
                                  command=root.destroy,
                                  activeforeground='red')

        self.message_label.grid(row=1, column=1)
        self.confirm_button.grid(row=3, column=0)
        self.exit_button.grid(row=3, column=2)

    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)
Beispiel #28
0
	def __init__(self, parent=None, app=None, **kwargs):
		Table.__init__(self, parent, **kwargs)

		self.app = app

		self.figList = [None] * len(self.model.df)
		self.spikeClipList = [None] * len(self.model.df)
		self.spikeDetectionList = [None] * len(self.model.df)
 def add_col(self):
     df = pd.read_csv('empsal.csv')
     df['conv'] = (df.salary * 10) // 100
     df['total'] = df.salary + df.hra + df.conv
     self.f = Frame(root, height=200, width=300)
     self.f.pack(fill=BOTH, expand=1)
     self.table = Table(self.f, dataframe=df, read_only=True)
     self.table.show()
Beispiel #30
0
def pandas_interface():

    df = pd.read_excel("datos_papers.xlsx", sheet_name='datos')
    top = Toplevel()
    pt = Table(top, dataframe=df, showtoolbar=True, showstatusbar=True)
    pt.show()

    pass
Beispiel #31
0
    def __init__(self, master):     
        # 1 is csv, 2 is file with correct fields

        # txt,xls,append file names
        self.filename1=""
        self.filename2=""
        self.filename3=""

        self.trouble=[]
        self.maxwordlen=[]
        self.checklabel= StringVar()
        self.countlabel= StringVar()
        self.neglabel=StringVar() 
        # make frames for each step
        self.processing = Frame(master, bg="#DAF7A6" )
        Frame.__init__(self,self.processing)
        self.processing.grid(column=0,row=1)
        
                
        # Make Frames for tables, buttons and output
        self.stuffframe = Frame(self.processing,bg="#DAF7A6")
        self.stuffframe.grid(column = 0,row = 0, sticky=W+N)
        
        # Frames for tables
        tableframe1 = Frame(self.processing,bg="#DAF7A6")
        tableframe1.grid(column=2,row = 0, sticky = N)
        self.stuffframe2 = Frame(tableframe1)
        self.stuffframe2.grid(row=0,column=0, sticky=E)
        
        # This is the Table Frame for showing data
        self.f1 = Frame(tableframe1)
        self.f1.grid(row = 0, column = 3, columnspan=25, rowspan=15, sticky = N)
        
        #tableframe2 = Frame(self.processing,bg="#DAF7A6")
        #tableframe2.grid(column=2,row = 1, sticky = N)
        self.stuffframe3 = Frame(tableframe1)
        self.stuffframe3.grid(row=1,column=0, sticky=E)

        # This is the table frame for negatives
        self.f2 = Frame(tableframe1, bg="#DAF7A6")
        self.f2.grid(row = 1, column = 3, columnspan=25, rowspan=15,pady=(320,0),
                sticky = S)
        
         
        #self.toplevel = Toplevel()
        
        #Buttons/Text
        self.title2 = Label(self.stuffframe,text="Cleaning & Processing Data",
                font = "-weight bold")
        self.title2.grid(row=0,column=0,sticky=W+N)
        
        self.title3 = Label(self.stuffframe,text="Visit Github.com/ljstrnadiii")
        self.title3.grid(row=1,column=0,sticky=W+N)
        

        self.text1 = Label(self.stuffframe, text="Choose files:")
        self.text1.grid(row=2,column=0, pady =(10,0),sticky=W)
 
        self.button1= Button(self.stuffframe, text="Scanned txt", 
                command = self.browsecsv)
        self.button1.grid(row=3, column=0, sticky=W)

        self.button7= Button(self.stuffframe, text="amend data",
                command = self.ammend)
        self.button7.grid(row=4, column=0, sticky=W)

        self.button2= Button(self.stuffframe, text="Valid xls", 
                command = self.browsevalid)
        self.button2.grid(row=5, column=0, sticky = W)

        self.text2 = Label(self.stuffframe, text="Process:")
        self.text2.grid(row=7,column=0, pady =(10,0), sticky = W)
        
        self.button3= Button(self.stuffframe, text="Correct",
                command = self.check ) 
        self.button3.grid(row=8, column=0,sticky=W+N )
        
        self.button4= Button(self.stuffframe, text="Get Count", 
                command = self.count)
        self.button4.grid(row=9, column=0, sticky = W+N)
        label1 = Label(self.processing,text ="")

        
        self.title_instr = Label(self.stuffframe,text="Procedure: show negative, edit, update, repeat")
        self.title_instr.grid(row=15,column=0,sticky=W+N)

        
        self.button5 = Button(self.stuffframe, text="show negatives", 
                command = self.fixnegs)

        self.button5.grid(row=16, column = 0, sticky = W)
        
        self.button6 = Button(self.stuffframe, text="update", 
                command = self.update)

        self.button6.grid(row=17, column = 0, sticky = W)

                # setting tables up 
        self.pt1 = Table(self.f1, rows=14,column=24,
                                showtoolbar=False, showstatusbar=False) 
        self.pt2 = Table(self.f2, rows=17, column=24,
                                showtoolbar=False, showstatusbar=False) 
        self.pt1.show()
        self.pt2.show()
        
        self.processing.config(bd=5)
Beispiel #32
0
class processingFrame(Frame):       
    def __init__(self, master):     
        # 1 is csv, 2 is file with correct fields

        # txt,xls,append file names
        self.filename1=""
        self.filename2=""
        self.filename3=""

        self.trouble=[]
        self.maxwordlen=[]
        self.checklabel= StringVar()
        self.countlabel= StringVar()
        self.neglabel=StringVar() 
        # make frames for each step
        self.processing = Frame(master, bg="#DAF7A6" )
        Frame.__init__(self,self.processing)
        self.processing.grid(column=0,row=1)
        
                
        # Make Frames for tables, buttons and output
        self.stuffframe = Frame(self.processing,bg="#DAF7A6")
        self.stuffframe.grid(column = 0,row = 0, sticky=W+N)
        
        # Frames for tables
        tableframe1 = Frame(self.processing,bg="#DAF7A6")
        tableframe1.grid(column=2,row = 0, sticky = N)
        self.stuffframe2 = Frame(tableframe1)
        self.stuffframe2.grid(row=0,column=0, sticky=E)
        
        # This is the Table Frame for showing data
        self.f1 = Frame(tableframe1)
        self.f1.grid(row = 0, column = 3, columnspan=25, rowspan=15, sticky = N)
        
        #tableframe2 = Frame(self.processing,bg="#DAF7A6")
        #tableframe2.grid(column=2,row = 1, sticky = N)
        self.stuffframe3 = Frame(tableframe1)
        self.stuffframe3.grid(row=1,column=0, sticky=E)

        # This is the table frame for negatives
        self.f2 = Frame(tableframe1, bg="#DAF7A6")
        self.f2.grid(row = 1, column = 3, columnspan=25, rowspan=15,pady=(320,0),
                sticky = S)
        
         
        #self.toplevel = Toplevel()
        
        #Buttons/Text
        self.title2 = Label(self.stuffframe,text="Cleaning & Processing Data",
                font = "-weight bold")
        self.title2.grid(row=0,column=0,sticky=W+N)
        
        self.title3 = Label(self.stuffframe,text="Visit Github.com/ljstrnadiii")
        self.title3.grid(row=1,column=0,sticky=W+N)
        

        self.text1 = Label(self.stuffframe, text="Choose files:")
        self.text1.grid(row=2,column=0, pady =(10,0),sticky=W)
 
        self.button1= Button(self.stuffframe, text="Scanned txt", 
                command = self.browsecsv)
        self.button1.grid(row=3, column=0, sticky=W)

        self.button7= Button(self.stuffframe, text="amend data",
                command = self.ammend)
        self.button7.grid(row=4, column=0, sticky=W)

        self.button2= Button(self.stuffframe, text="Valid xls", 
                command = self.browsevalid)
        self.button2.grid(row=5, column=0, sticky = W)

        self.text2 = Label(self.stuffframe, text="Process:")
        self.text2.grid(row=7,column=0, pady =(10,0), sticky = W)
        
        self.button3= Button(self.stuffframe, text="Correct",
                command = self.check ) 
        self.button3.grid(row=8, column=0,sticky=W+N )
        
        self.button4= Button(self.stuffframe, text="Get Count", 
                command = self.count)
        self.button4.grid(row=9, column=0, sticky = W+N)
        label1 = Label(self.processing,text ="")

        
        self.title_instr = Label(self.stuffframe,text="Procedure: show negative, edit, update, repeat")
        self.title_instr.grid(row=15,column=0,sticky=W+N)

        
        self.button5 = Button(self.stuffframe, text="show negatives", 
                command = self.fixnegs)

        self.button5.grid(row=16, column = 0, sticky = W)
        
        self.button6 = Button(self.stuffframe, text="update", 
                command = self.update)

        self.button6.grid(row=17, column = 0, sticky = W)

                # setting tables up 
        self.pt1 = Table(self.f1, rows=14,column=24,
                                showtoolbar=False, showstatusbar=False) 
        self.pt2 = Table(self.f2, rows=17, column=24,
                                showtoolbar=False, showstatusbar=False) 
        self.pt1.show()
        self.pt2.show()
        
        self.processing.config(bd=5)
        

    # functions made for Window
    
    def browsecsv(self):
        Tk().withdraw() 
        self.filename1 = askopenfilename()
        filename = ntpath.basename(self.filename1)
        Label(self.stuffframe,text=filename, wraplength = 200
                , justify = LEFT).grid(row=10, column=0, sticky=W)
    
    def ammend(self):
        Tk().withdraw()
        self.filename3 = askopenfilename()
        filename = ntpath.basename(self.filename3)
        Label(self.stuffframe,text=filename, wraplength = 200
                 , justify = LEFT).grid(row=11, column=0, sticky=W)

    

    def browsevalid(self):
        Tk().withdraw() 
        self.filename2 = askopenfilename()
        filename = ntpath.basename(self.filename2)
        Label(self.stuffframe,text=filename ).grid(row=12, column=0, sticky = W)

    def check(self):
        text1 = proc.correctfields(self.filename1, self.filename2)
        proc.ammend(self.filename1,self.filename3)
        self.checklabel.set(text1)
        #label1 = Label(self.stuffframe,textvariable = self.checklabel, \
         #   wraplength=250, justify=LEFT)
        #label1.grid(row=13,column=0,  sticky = W)
        
    def count(self):
        self.corrected, self.trouble, self.text2 = \
        proc.getcount(self.filename1) 
               # self.pt1, \
        self.countlabel.set(self.text2)
        Label2 = Label(self.stuffframe, text = self.countlabel.get(), \
            wraplength = 250,justify=LEFT)
        Label2.grid(row = 14, column = 0, sticky =W)
        self.corrected = self.corrected.fillna(0)
        self.pt1.model.df = self.corrected
        self.pt1.redraw()
        
    def fixnegs(self):
        if len(self.trouble)>0:
            dq = self.corrected.ix[self.corrected[ \
                    "Account_Number"]==self.trouble[-1][-1],:]
            print(list(dq))
            dq = dq[["Store","Inv_Type","Date",self.trouble[-1][-2]]]
            
            # where is the neg value and what it is. append it in a column
            where = self.trouble[-1][-3]
            negcol=np.zeros(len(dq))
            negcol[where-1]=self.trouble[-1][-6]
            dq["value"]=negcol
            
            # uncomment for label of neg value
            # self.n = (self.trouble[-1][-5].isoformat()[0:10],self.trouble[-1][-6])
            #self.neglabel.set(str(self.n))
            #Label3 = Label(self.stuffframe, text = self.neglabel.get(), \
             #   wraplength = 250,justify=LEFT)
            #Label3.grid(row=15,column=0,sticky=W)
            
            dq = pd.DataFrame(dq)
            dq = dq.fillna(0)
            dq[list(dq)[-2]]= dq[list(dq)[-2]].astype(int)
            dq[list(dq)[-1]]= dq[list(dq)[-1]].astype(int)
            dq[list(dq)[-4]]= dq[list(dq)[-4]].astype(int)

            self.pt2.model.df = dq#.loc[:last+1,:]
            self.pt2.redraw()
        # pop last element from list assuming user will update before fixnegs again
            self.trouble.pop() 
        else:
            self.pt2.clearTable()
            self.pt2.redraw()
         
        
    def update(self): #note: i dont think i need a child table:
        # try to just create a table in fixnegs and below in update call on the 
        # df o update accordingly. consider the indexes though
        
        self.pt1.model.df.update(self.pt2.model.df)
        self.pt1.redraw()

        #uncomment to save 
        self.pt1.model.df.to_csv(self.filename1, index=False)
    def Report(ImageFrame, ImageLabel, ComplaintsOTButton,ProductIssueButton,CompanyButton,ReportButton):
        try:
            global REFRESH_COT_FLG,ReportRefreshFlag
            ReportRefreshFlag=True
            REFRESH_COT_FLG=True
            ComplaintsOTButton.config(state=DISABLED)
            ProductIssueButton.config(state=DISABLED)
            CompanyButton.config(state=DISABLED)
            ReportButton.config(state=DISABLED)
            ImageLabel.destroy()

            TopFetchFrame=Frame(ImageFrame)
            TopFetchFrame.pack(side=TOP)

            BottomFrame=Frame(ImageFrame)
            BottomFrame.pack()
            f = plt.figure()


            pt = Table(TopFetchFrame,showtoolbar=True)
            pt.model=TableModel(rows=20,columns=5)
            pt.show()

            def ReportAnimate(i):
                try:
                    global REFRESH_COT_FLG
                    if REFRESH_COT_FLG is True:
                        global FilteredDF,ReportRefreshFlag
                        ax1=f.add_subplot(131)
                        ax1.clear()
                        ax1.pie(FilteredDF.Issue.groupby([FilteredDF.CompanyResponseConsumer]).count(),
                                labels=pd.unique(FilteredDF.CompanyResponseConsumer),shadow=True,autopct='%1.1f%%',
                                            startangle=90)
                        ax1.set_title('Company Response')
                        ax2=f.add_subplot(132)
                        ax2.clear()
                        ax2.pie(FilteredDF.Issue.groupby([FilteredDF.TimelyResponseSts]).count(),
                                labels=pd.unique(FilteredDF.TimelyResponseSts),shadow=True,autopct='%1.1f%%',
                                            startangle=90)
                        ax2.set_title('Timely Closure')
                        ax3=f.add_subplot(133)
                        ax3.clear()
                        ax3.pie(FilteredDF.Issue.groupby([FilteredDF.ConsumerDisputedSts]).count(),
                                labels=pd.unique(FilteredDF.ConsumerDisputedSts),shadow=True,autopct='%1.1f%%',
                                            startangle=90)
                        ax3.set_title('User Satisfaction')

                        ReportDF=FilteredDF
                        ReportDF['Issue Count']=ReportDF.ComplaintId

                        PivotDF=ReportDF.pivot_table(['Issue Count'],
                                                        index=['Company'],
                                                        columns=['Product'],
                                                        aggfunc='count',
                                                        fill_value =0
                                                      )
                        PivotColumnIndex=list(PivotDF.index.values)
                        DF=pd.DataFrame(PivotDF,index=PivotColumnIndex)

                        if ReportRefreshFlag is True:
                            pt.updateModel(TableModel(dataframe=DF))
                            pt.showIndex()
                            pt.redraw()
                            ReportRefreshFlag=False
                        else:
                            pt.updateModel(TableModel(dataframe=DF))
                            pt.showIndex()
                            pt.redraw()

                        REFRESH_COT_FLG=False

                except Exception as e:
                    print(e)

            canvas = FigureCanvasTkAgg(f, BottomFrame)
            canvas.show()
            canvas.get_tk_widget().pack()
            ani=animation.FuncAnimation(f,ReportAnimate,1000)

        except Exception as e:
            print('')