Spaces:
Sleeping
Sleeping
| #analyze.py | |
| import pandas as pd | |
| from ydata_profiling import ProfileReport | |
| def analyze_csv(file_path): | |
| df = pd.read_csv(file_path) | |
| profile = ProfileReport(df, title="Profiling Report", minimal=True, explorative=True) | |
| summary = df.describe(include='all').to_dict() | |
| column_info = { | |
| col: { | |
| "dtype": str(df[col].dtype), | |
| "missing_pct": df[col].isnull().mean() * 100, | |
| "unique_vals": df[col].nunique(), | |
| "example_vals": df[col].dropna().unique()[:5].tolist() | |
| } | |
| for col in df.columns | |
| } | |
| return { | |
| "summary": summary, | |
| "columns": column_info, | |
| "shape": df.shape | |
| } | |