mirror of
https://github.com/Sosokker/Packaged-Food-Explorer.git
synced 2025-12-18 20:54:05 +01:00
Add Descriptive.py|Show all data descriptive stat
This commit is contained in:
parent
1e528e3a65
commit
1b918d88ef
31
Essential/descriptive.py
Normal file
31
Essential/descriptive.py
Normal file
@ -0,0 +1,31 @@
|
||||
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()
|
||||
Loading…
Reference in New Issue
Block a user