mirror of
https://github.com/Sosokker/Packaged-Food-Explorer.git
synced 2025-12-19 05:04:06 +01:00
31 lines
995 B
Python
31 lines
995 B
Python
import sqlite3
|
|
import tkinter as tk
|
|
from tkinter import ttk
|
|
import pandas as pd
|
|
|
|
class Descriptive:
|
|
def __init__(self, data):
|
|
self.data = data
|
|
|
|
def show_statistics(self):
|
|
statistics = self.data.describe()
|
|
window = tk.Toplevel()
|
|
tree = ttk.Treeview(window)
|
|
columns = statistics.columns.tolist()
|
|
tree["columns"] = columns
|
|
tree.heading("#0", text="Statistic")
|
|
for column in columns:
|
|
tree.heading(column, text=column)
|
|
|
|
for stat in statistics.index:
|
|
values = statistics.loc[stat].tolist()
|
|
tree.insert("", "end", text=stat, values=values)
|
|
|
|
tree.pack()
|
|
window.mainloop()
|
|
|
|
|
|
|
|
# df = pd.read_sql_query("SELECT * FROM food_data", sqlite3.connect(r"D:\Food-Nutrient-Viewer-Tkinter\Essential\data\food_data.db"))
|
|
# descriptive = Descriptive(df[['product_name', 'carbohydrates_100g','sugars_100g','energy-kcal_100g','fat_100g','proteins_100g']])
|
|
# descriptive.show_statistics() |