from functions.filter import filter_ngr
from functions.filter import extract_eid_information

def clean_data():
    selected = data_list.curselection()
    if selected:
        dataset_name = data_list.get(selected[0])
        df = data_dict.get(dataset_name)
        
        if df is not None:
            try:
                df.drop_duplicates(inplace=True)
                df.dropna(inplace=True)

                str_cols = df.select_dtypes(include=['object']).columns
                for col in str_cols:
                    df[col] = df[col].str.lower()

                data_dict[dataset_name] = df

                messagebox.showinfo("Success", "Data cleaned successfully")
            except Exception as e:
                messagebox.showerror("Error", str(e))
        else:
            messagebox.showinfo("Error", "No data selected")
    else:
        messagebox.showinfo("Error", "No dataset selected")