By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
(For Python Data Scientists Who Need to Move Fast Without Guessing)
Data profiling is the process of automatically summarizing a dataset’s structure, content, and quality—think of it as a health check for your data. Automated EDA (Exploratory Data Analysis) takes this further by generating interactive reports that highlight distributions, correlations, missing values, and anomalies without you writing a single df.describe().
df.describe()
NaN
-999999
Real-world scenario:You’re a data scientist at a fintech startup. Your team just received a 10GB CSV of loan applications. Your boss asks: - "Are there any missing values in critical fields like income or credit score?" - "What’s the distribution of loan amounts? Are there outliers?" - "Are there duplicate records?"
Without automated profiling, you’d spend hours writing custom scripts. With it, you generate a full report in 2 minutes and answer all questions before the meeting.
minimal=True
email
pip install pandas pandas-profiling sweetviz openpyxl # openpyxl for Excel support
import pandas as pd from pandas_profiling import ProfileReport # Load data (Titanic dataset) url = "https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv" df = pd.read_csv(url) # Generate report (minimal=True for faster output) profile = ProfileReport(df, title="Titanic Dataset Profiling", minimal=False) profile.to_file("titanic_report.html") # Saves as interactive HTML
Expected Output:- A 10MB HTML file (titanic_report.html) that opens in your browser.- Key sections you’ll see: - Overview (variables, missing values, duplicates). - Variables (histograms, descriptive stats for each column). - Correlations (heatmap of relationships). - Warnings (e.g., "Age has 19.9% missing values").
titanic_report.html
import sweetviz as sv # Split data into "survived" vs. "not survived" train = df[df["Survived"] == 1] test = df[df["Survived"] == 0] # Generate comparative report report = sv.compare([train, "Survived"], [test, "Not Survived"]) report.show_html("titanic_comparison.html")
Expected Output:- A side-by-side comparison of: - Age distributions (e.g., "Did children survive more?"). - Class distributions (e.g., "Did 1st-class passengers survive more?"). - Missing values (e.g., "Did survivors have more complete data?").
# Define rules (e.g., "Fail if >20% missing in critical columns") critical_columns = ["Age", "Fare", "Pclass"] missing_threshold = 0.2 for col in critical_columns: missing_pct = df[col].isna().mean() if missing_pct > missing_threshold: raise ValueError(f"❌ Column '{col}' has {missing_pct:.1%} missing values (threshold: {missing_threshold:.0%})") else: print(f"✅ Column '{col}' passed (missing: {missing_pct:.1%})")
Production Use Case:- Add this to your CI/CD pipeline to fail builds if data quality is poor.- Log warnings to Slack/email for non-critical issues.
pandas-profiling
df.sample(10000)
data_v1_profile.html
data_v2_profile.html
df["email"] = df["email"].apply(lambda x: "REDACTED")
sweetviz
anonymize
sweetviz.compare()
report_2023-10-01.html
matplotlib
❌ seaborn (only visualizations)
seaborn
"How do you compare two datasets (e.g., train vs. test)?"
❌ df.describe() (only shows stats, not comparisons)
"What’s the fastest way to profile a 10GB dataset?"
❌ Profile the full dataset (slow).
"How do you automate data quality checks in a pipeline?"
minimal=False
Challenge:You’re given a dataset (challenge_data.csv) with 3 columns: - user_id (unique identifier) - purchase_amount (numeric) - purchase_date (string, format: "YYYY-MM-DD")
challenge_data.csv
user_id
purchase_amount
purchase_date
"YYYY-MM-DD"
Task:1. Generate a pandas-profiling report and identify one data quality issue.2. Write a Python function to fix the issue.3. Generate a new report to verify the fix.
Solution:
import pandas as pd from pandas_profiling import ProfileReport # Load data df = pd.read_csv("challenge_data.csv") # Step 1: Generate report (look for issues) profile = ProfileReport(df, title="Challenge Data Profiling") profile.to_file("challenge_report.html") # Step 2: Fix issue (e.g., "purchase_date" is a string, not datetime) df["purchase_date"] = pd.to_datetime(df["purchase_date"]) # Step 3: Verify fix profile_fixed = ProfileReport(df, title="Fixed Data Profiling") profile_fixed.to_file("challenge_report_fixed.html")
Why This Works:- The first report will flag purchase_date as a string (not datetime).- Converting to datetime enables time-based analysis (e.g., "purchases by month").- The second report confirms the fix.
datetime
pip install pandas pandas-profiling sweetviz
ProfileReport(df).to_file("report.html")
ProfileReport(df, minimal=True).to_file("report.html")
sv.compare([df1, "Group 1"], [df2, "Group 2"]).show_html("compare.html")
df.isna().mean() > 0.2
profile.to_file("/tmp/report.html"); s3.upload_file("/tmp/report.html", "bucket", "report.html")
sv.analyze(df, target_feat="target", feat_cfg=sv.FeatureConfig(skip=["email"]))
⚠️ Exam Traps:- Default pandas-profiling is slow for big data → Use minimal=True.- sweetviz requires both datasets to have the same columns → Pre-process first.- HTML reports can be large → Compress before sharing (gzip report.html).
gzip report.html
Final Tip:
"Automated EDA isn’t about replacing your brain—it’s about freeing your brain to focus on the hard problems (e.g., feature engineering, model tuning). Always validate the report’s findings with domain knowledge."
Now go profile some data! ?
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.