Загрузка...

check missing values | Data Analysis using Python Tkinter | Part 2

Code : - ## Data Analysis using Python Tkinterimport tkinter as tk
from tkinter import filedialog, messagebox , scrolledtext

import pandas as pd

df = None # Global

root = tk.Tk()
root.title("Data Analysis using Python Tkinter")
root.geometry("500x500")

# file upload dialog and button
def upload_file():
global df
filepath = filedialog.askopenfilename(
title="Select a file",
filetypes = (
("Excel files " , "*.xlsx; *.xls"),
("CSV Files", "*.csv") ## to accept only excel and csv files
,)
)

if filepath:
try:
if filepath.endswith(".csv"):
df=pd.read_csv(filepath)
else:
df=pd.read_excel(filepath)

label.configure(text=f"Selected file successfully : \n{filepath}\n Rows: {df.shape[0]}|Columns: {df.shape[1]}")
btn_check_missing.configure(state="normal")
except Exception as e:
messagebox.showerror("Error",f"Could not Load file: \n{e}")
else:
label.configure(text="No file selected")

def check_missing():
if df is not None:
result = df.isnull().sum().to_string()
text_box.delete(1.0, tk.END)
text_box.insert(tk.END , "Missing Values \n")
text_box.insert(tk.END,result)
else:
messagebox.showwarning("warning","Please Upload a file first")

btn = tk.Button(root, text = "Upload file" , command=upload_file,padx=10,pady=10)
btn.pack(pady=20)

label = tk.Label(root,text="No file selected", wraplength=350,justify="center")
label.pack(pady =10)

btn_check_missing = tk.Button(root , text = "Check Missing Values" , command=check_missing , state="disabled")
btn_check_missing.pack(pady=10)

text_box = scrolledtext.ScrolledText(root, width=70 , height=15, wrap=tk.WORD)
text_box.pack(pady=10)

root.mainloop()

Видео check missing values | Data Analysis using Python Tkinter | Part 2 канала SE CS Academy
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять