Excel_AI_Agent / src /cleaner.py
Kunjeti's picture
Upload 7 files
f0cbc29 verified
Raw
History Blame Contribute Delete
463 Bytes
import pandas as pd
def clean_dataframe(df):
df = df.drop_duplicates()
for col in df.columns:
if df[col].dtype == "object":
df[col] = (
df[col]
.astype(str)
.str.strip()
)
if pd.api.types.is_numeric_dtype(
df[col]
):
df[col] = df[col].fillna(
df[col].median()
)
return df