Exploratory Data Analysis: lesson 2 of 3

Exploratory Data Analysis

PATH 01MODULE 08LESSON 02 OF 03Next: Finding Patterns, Relationships, and Data Quality Issues

Univariate and Bivariate Analysis

Analyze individual variables and meaningful relationships in a customer churn dataset.

Beginner17 min readedaunivariate-analysisbivariate-analysiscorrelation

Concept

Univariate analysis studies one variable at a time; bivariate analysis studies the relationship between two. Together they show what values are typical, which groups differ, and which questions deserve deeper investigation.

Why It Matters

An overall churn rate can hide large differences by contract type. An average monthly charge can hide a skewed distribution. Looking at one variable first provides context before interpreting a relationship.

Univariate Analysis

For a numerical field such as monthly_charges, inspect count, mean, median, standard deviation, minimum, maximum, and quartiles. A histogram shows shape; a box plot shows median, spread, and potential outliers. For categorical fields such as contract_type or region, use value counts, proportions, and bar charts.

df["monthly_charges"].describe()
df["contract_type"].value_counts(normalize=True)
df["monthly_charges"].plot.hist(bins=20)

The proportion output answers how the observed customers are distributed across contract types. It does not show churn differences yet.

Bivariate Analysis

Numerical versus numerical questions, such as age and annual spending, use a scatter plot and possibly correlation. Categorical versus numerical questions, such as monthly charge by churn status, use grouped summaries and box plots. Categorical versus categorical questions, such as churn by contract type, use a crosstab and row or column proportions.

df.groupby("churn")["monthly_charges"].agg(["count", "mean", "median"])
pd.crosstab(df["contract_type"], df["churn"], normalize="index")
df[["tenure_months", "monthly_charges", "support_calls"]].corr()

The grouped output compares typical monthly charges by churn status while retaining counts. The crosstab gives the observed churn proportion inside each contract group. A correlation near zero means little linear relationship; a curved relationship or important subgroup difference can still exist. Correlation never proves causation.

Failure Signals

Common Mistakes

  1. Comparing averages without sample sizes or distributions.
  2. Ignoring categorical variables because they do not have a mean.
  3. Treating a scatter plot pattern as causal evidence.
  4. Drawing conclusions from a very small segment.

Best Practices

Start univariate, then choose a bivariate comparison that answers a question. Use counts with rates, inspect outliers before removing them, and segment a surprising relationship to see whether it holds across groups.

Data Science Perspective

These checks support feature understanding, segmentation, visualization, and later model diagnostics. They generate hypotheses, not final claims: higher churn in monthly contracts may reflect pricing, tenure, or service experience.

Interview Perspective

Question: What would you do if two features are highly correlated? Answer: inspect their definitions, distributions, and possible redundancy; then decide based on the analysis or model goal rather than deleting one automatically. Follow-up: why is zero correlation not proof of no relationship?

Practice Questions

  1. Which chart would inspect the distribution of customer age?
  2. How would you compare churn rate by contract type in Pandas?
  3. Why should a group mean be reported with its count?

Quick Quiz

  1. What does univariate mean? Answer: one variable at a time.
  2. Which plot suits two numerical variables? Answer: a scatter plot.
  3. Does correlation imply causation? Answer: no.

Practical Interpretation

For one numerical variable, ask about center, spread, skew, and unusual values. A histogram of monthly_charges may show two peaks, suggesting distinct plans; a box plot may show a long upper tail that makes the mean less representative than the median. For categories, inspect counts and proportions: a rare contract type can produce a dramatic-looking churn rate from very few customers.

For two variables, choose the comparison deliberately. A scatter plot of tenure and charges can reveal a curved or segmented relationship that Pearson correlation misses. Correlation measures linear association only; near-zero correlation does not mean there is no useful nonlinear relationship or interaction. For contract type and churn, a crosstab with row proportions shows observed churn rates; compare group sizes before acting. For churn status and monthly charges, report group count, mean, median, and a box plot, then ask whether tenure or plan differences explain the gap.

Key Takeaway

Key Takeaways

Univariate analysis explains each field; bivariate analysis compares meaningful pairs. Use summaries, plots, counts, and context to form careful questions about the data.

Next Lesson

Next, turn EDA observations into quality checks and actionable next steps.

Finish this lesson on your terms

Mark it complete when you have worked through the material and are ready to move on.