Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
-
from io import BytesIO
|
| 4 |
-
|
| 5 |
-
st.set_page_config(
|
| 6 |
-
page_title="Excel AI Agent",
|
| 7 |
-
layout="wide"
|
| 8 |
-
)
|
| 9 |
-
|
| 10 |
-
st.title("📊 Excel AI Agent")
|
| 11 |
-
|
| 12 |
-
uploaded_file = st.file_uploader(
|
| 13 |
-
"Upload File",
|
| 14 |
-
type=["xlsx","csv"]
|
| 15 |
-
)
|
| 16 |
-
|
| 17 |
-
if uploaded_file:
|
| 18 |
-
|
| 19 |
-
if uploaded_file.name.endswith(".csv"):
|
| 20 |
-
df = pd.read_csv(uploaded_file)
|
| 21 |
-
else:
|
| 22 |
-
df = pd.read_excel(uploaded_file)
|
| 23 |
-
|
| 24 |
-
st.subheader("Data Preview")
|
| 25 |
-
st.dataframe(df.head())
|
| 26 |
-
|
| 27 |
-
col1,col2,col3 = st.columns(3)
|
| 28 |
-
|
| 29 |
-
with col1:
|
| 30 |
-
st.metric("Rows",len(df))
|
| 31 |
-
|
| 32 |
-
with col2:
|
| 33 |
-
st.metric(
|
| 34 |
-
"Missing Values",
|
| 35 |
-
int(df.isnull().sum().sum())
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
with col3:
|
| 39 |
-
st.metric(
|
| 40 |
-
"Duplicates",
|
| 41 |
-
int(df.duplicated().sum())
|
| 42 |
-
)
|
| 43 |
-
|
| 44 |
-
if st.button("Clean Data"):
|
| 45 |
-
|
| 46 |
-
df = df.drop_duplicates()
|
| 47 |
-
|
| 48 |
-
for col in df.columns:
|
| 49 |
-
|
| 50 |
-
if df[col].dtype == "object":
|
| 51 |
-
df[col] = (
|
| 52 |
-
df[col]
|
| 53 |
-
.astype(str)
|
| 54 |
-
.str.strip()
|
| 55 |
-
)
|
| 56 |
-
|
| 57 |
-
st.success("Cleaning Complete")
|
| 58 |
-
|
| 59 |
-
output = BytesIO()
|
| 60 |
-
|
| 61 |
-
df.to_excel(
|
| 62 |
-
output,
|
| 63 |
-
index=False,
|
| 64 |
-
engine="openpyxl"
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
-
st.download_button(
|
| 68 |
-
"Download Cleaned File",
|
| 69 |
-
output.getvalue(),
|
| 70 |
-
"cleaned.xlsx"
|
| 71 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|