Univariate and Bivariate Analysis
Explore univariate and bivariate analysis techniques to validate and understand your data during exploratory data analysis. Learn to identify missing values, outliers, unusual distributions, and relationships between variables, enabling you to clean and prepare data effectively for further modeling.
An employee attrition table can look ready after validation while still hiding a negative tenure_months value, a heavily right-skewed monthly_income column, or a department with unusually high attrition. Lightweight exploratory data analysis (EDA) finds these screening signals before modeling turns them into assumptions.
Univariate analysis examines one column at a time. It answers questions such as whether monthly_income contains missing values, whether tenure_months has plausible values, and how many employees appear in each department. Bivariate analysis examines two columns together. It answers questions such as whether attrition rates differ across department values or whether income tends to rise with tenure.
Neither kind of analysis proves why a pattern exists. The immediate goal is narrower and more useful at this stage. We identify data issues to revisit and relationships worth checking more carefully later.
Inspect one column before comparing columns
Because a relationship can only be trusted after each input has passed a basic inspection, start with missing rates, summary statistics, and category counts. For an attrition table, describe() gives the count, center, spread, and extremes for tenure_months and monthly_income. A missing-rate calculation shows whether a summary excludes many records. value_counts() shows whether department contains an unexpected rare label or an imbalance that makes later comparisons unstable.
Lines 4–22: The DataFrame is created in-memory with one intentionally invalid
tenure_monthsvalue (-3) and one missingmonthly_income(None) so the later missing-rate and validation screens have something real to ...