Fundamentals of Business Analytics

Chapter 6
Data Preparation and Exploratory Analytics

Bachelors Program in Business Analytics
Fundamentals of Business Analytics   •   Bachelor

Data Preparation and Exploratory Analytics

Introduction

Business analytics is only as reliable as the data on which it is based. Organizations often collect data from enterprise systems, websites, mobile applications, spreadsheets, sensors, surveys, and external providers. These sources differ in structure, definitions, units, time periods, and quality. Before analysis begins, an analyst must therefore establish whether the data are accurate enough, complete enough, and appropriately structured for the intended decision.

Data preparation is the disciplined process of profiling, cleaning, integrating, transforming, and documenting data. Exploratory data analysis (EDA) then uses numerical summaries and visual or tabular methods to understand distributions, relationships, unusual observations, and possible explanations. Preparation and exploration are not strictly separate stages: EDA reveals quality problems, while cleaning changes the patterns that EDA reveals.

This chapter presents a practical framework for preparing data and conducting exploratory analytics while preserving analytical validity, transparency, and ethical responsibility.

Learning Objectives

By the end of this chapter, you should be able to:

  1. Explain the role of data profiling and data quality dimensions.
  2. Identify and address missing values, duplicates, outliers, and inconsistent records.
  3. Integrate data from multiple sources using appropriate keys and validation checks.
  4. Transform data for analysis without introducing avoidable bias or leakage.
  5. Summarize data using distributions, cross-tabulations, correlations, and segmentation.
  6. Diagnose potential relationships while distinguishing association from causation.
  7. Document preparation decisions and evaluate their business, ethical, and governance implications.

1. The Data Preparation–Exploration Cycle

A useful workflow is iterative rather than purely linear:

  1. Define the analytical purpose. Specify the business question, unit of analysis, target population, time period, and decision to be supported.
  2. Acquire and inventory data. Record sources, owners, formats, refresh dates, definitions, and access restrictions.
  3. Profile the data. Inspect row counts, data types, ranges, missingness, uniqueness, and relationships among fields.
  4. Clean and integrate. Resolve errors, duplicates, incompatible formats, and unreliable joins.
  5. Transform and engineer variables. Create consistent measures, categories, dates, ratios, and analytical features.
  6. Explore and diagnose. Examine distributions, associations, segments, and unusual records.
  7. Validate and document. Test assumptions, compare totals with trusted sources, and record every material decision.
  8. Prepare an analysis-ready dataset. Preserve a reproducible process and retain the original data securely.

The unit of analysis must be explicit. A row may represent a customer, order, order line, visit, account-month, or product-day. Confusing these units can produce incorrect averages and double counting. For example, joining a customer table to an order-line table creates multiple rows per customer; a customer-level average calculated afterward may unintentionally weight customers with more orders more heavily.

2. Data Quality and Profiling

Data quality is multidimensional. Common dimensions include:

DimensionMeaningTypical diagnostic
AccuracyValues represent the real-world phenomenonCompare with authoritative records
CompletenessRequired values are presentMissing-value rates
ConsistencyValues agree across fields and sourcesReconcile totals and definitions
ValidityValues conform to permitted rulesRange, type, and format checks
UniquenessRecords are not unintentionally repeatedKey-uniqueness tests
TimelinessData are available and current enoughTimestamp and refresh checks

A profile should report, for each field, its data type, number of distinct values, missing count, minimum and maximum where meaningful, frequent categories, and suspected errors. For a variable X with n observations, the missingness rate is:

rmissing = m / n

where m is the number of missing observations and n is the total number of records. This rate is descriptive; it does not by itself determine whether deletion or imputation is appropriate.

Validation rules should reflect business meaning. Examples include: quantity must be a non-negative integer; order date cannot precede customer registration date; a country code must exist in a reference table; and an invoice total should approximately equal the sum of its line items after permitted discounts and taxes.

3. Missing Values

Missingness may be represented by blank cells, null values, special codes such as 999, text such as “unknown,” or impossible placeholders such as 0 for an unrecorded age. These representations should be standardized before analysis. A value can be missing because it was not collected, not applicable, refused, unavailable at the time, or lost during data transfer. The reason matters.

Three useful conceptual mechanisms are:

  • Missing completely at random (MCAR): missingness is unrelated to observed and unobserved values.
  • Missing at random (MAR): missingness is related to observed variables but, after accounting for them, not to the missing value itself.
  • Missing not at random (MNAR): missingness remains related to the unobserved value or an unmeasured process.

These are assumptions about a data-generating process, not labels that can always be proven from the dataset.

Common strategies are:

  • Deletion: Remove records or variables when missingness is small, plausibly random, and the resulting sample remains suitable. Listwise deletion can reduce sample size and bias results when missingness is systematic.
  • Simple imputation: Replace missing numeric values with a mean or median, or categorical values with a mode or explicit “unknown” category. Median imputation is less affected by extreme values, but single imputation understates uncertainty and can distort relationships.
  • Group-based imputation: Use a median or other estimate within relevant groups, such as region or product category, provided the groups are sufficiently large and substantively justified.
  • Model-based or multiple imputation: Estimate plausible values using other variables. Multiple imputation preserves uncertainty better than a single replacement, but requires suitable assumptions and diagnostics.
  • Missingness indicators: Add a flag showing whether a value was missing when the fact of missingness may itself carry information. This should be justified rather than applied automatically.

A good practice is to compare results under more than one plausible treatment. If conclusions change substantially, the uncertainty should be reported rather than hidden.

4. Duplicates and Inconsistent Records

Duplicates may be exact copies or near-duplicates. Exact duplicates can often be removed after confirming that repeated rows do not represent repeated events. Near-duplicates require entity resolution: determining whether “A. Rahman,” “Ayesha Rahman,” and “Ayesha R.” refer to the same customer.

A duplicate rule must be based on the business entity and event. A customer identifier should generally be unique in a customer master table, but not in a transaction table. Useful checks include composite keys, such as customer ID plus transaction timestamp, and record counts before and after deduplication.

Inconsistent records include spelling variations, mixed capitalization, multiple date formats, different currencies, obsolete product codes, and conflicting demographic classifications. Standardization may involve:

  • converting dates to a single unambiguous format;
  • mapping synonyms to a controlled vocabulary;
  • preserving original values alongside standardized values;
  • converting currencies using a documented rate and date;
  • distinguishing “not applicable” from “not reported”;
  • using reference tables for product, location, and organizational codes.

Do not silently overwrite source data. Retain raw fields, standardized fields, and a transformation log so that decisions can be audited.

5. Outliers and Anomalies

An outlier is an observation unusually distant from the rest of a distribution. It may indicate an error, a rare but valid event, a change in process, fraud, or a different population. It is not automatically a bad value.

For a numeric variable, the interquartile range is:

IQR = Q3 − Q1

where Q₁ is the first quartile and Q₃ is the third quartile. A conventional exploratory rule identifies low and high potential outliers as values below Q₁ − 1.5 × IQR or above Q₃ + 1.5 × IQR. This is a screening rule, not proof of error. It is most useful for continuous data and can flag many observations in skewed or highly heterogeneous populations.

The standardized score, or z-score, is:

zi = (xi − x̄) / s

where xᵢ is an observation, x̄ is the sample mean, and s is the sample standard deviation. A z-score describes distance in standard-deviation units. Rules such as |z| > 3 are heuristics and work less well for skewed distributions or small samples.

Appropriate responses include correcting a verified data-entry error, retaining a valid extreme observation, capping values for a clearly justified operational purpose, transforming a skewed variable, analyzing a separate segment, or using robust statistics. Winsorization replaces extreme values with selected percentile boundaries; it should be reported because it changes the data. Removing observations solely because they weaken a desired result is unacceptable.

6. Integrating Data from Multiple Sources

Integration combines data while preserving meaning. The central risks are incompatible definitions, nonmatching keys, different grain, and many-to-many joins.

A primary key uniquely identifies a record in a table. A foreign key references a key in another table. Before joining, establish:

  • the grain of each table;
  • whether the join is one-to-one, one-to-many, or many-to-many;
  • the expected match rate;
  • how unmatched records will be handled;
  • whether time validity matters.

Suppose a customer table has one row per customer and a transaction table has one row per transaction. A left join from customers to transactions retains all customers but repeats customer attributes for each transaction. An inner join excludes customers without matched transactions. Neither is automatically correct; the choice depends on the question.

After a join, compare row counts, distinct key counts, totals, and unmatched-key lists. A sudden multiplication of rows often signals an unintended many-to-many join. Definitions must also be reconciled: “sales” might mean gross invoice value in one source and net recognized revenue in another.

7. Transforming Data for Analysis

Transformation changes representation while aiming to preserve analytical meaning. Common transformations include:

  • Type conversion: dates, integers, decimals, and categorical values should be stored appropriately.
  • Scaling: standardization uses z = (x − μ) / σ, where μ is a population or reference mean and σ is its standard deviation. It is useful when variables have different scales, although it does not make a skewed distribution normal.
  • Log transformation: y = ln(x) requires x > 0 and can reduce right skew. If zeros exist, a justified alternative such as ln(1 + x) may be considered, but interpretation changes.
  • Categorization: age bands or spending tiers can aid communication, but categorization discards information and creates boundary effects.
  • Date features: year, month, weekday, tenure, and elapsed time can be derived, provided the reference date is appropriate.
  • Ratios and rates: revenue per customer or defect rate can be informative, but denominators must be defined and sufficiently reliable.

Analysts must prevent data leakage: using information that would not have been available at the time a prediction or decision was made. For example, a customer’s future cancellation status must not be used to prepare a model predicting current churn. Transformations estimated from data, such as means used for standardization or imputation, should generally be learned from the training period or training sample and then applied to later data.

8. Exploratory Data Analysis

EDA seeks to understand structure before formal modeling. It should combine domain knowledge with numerical and graphical evidence.

8.1 Univariate Distributions

For a numeric variable, examine center, spread, shape, and unusual values. The arithmetic mean is:

x̄ = (1 / n) ∑ᵢ₌₁ⁿ xᵢ

The sample variance and sample standard deviation are:

s² = [∑ᵢ₌₁ⁿ (xᵢ − x̄)²] / (n − 1)
s = √s²

The denominator n − 1 is used for the usual unbiased estimator of population variance under independent random sampling. These measures are sensitive to extreme observations. The median and interquartile range are often preferable for skewed data.

Histograms show the distribution of numeric values but depend on bin width. Box plots summarize quartiles and potential extremes. Bar charts suit categorical frequencies; percentages should identify their denominator. A distribution that is right-skewed may have a mean larger than its median, but this pattern is a clue rather than a universal rule.

8.2 Cross-Tabulations

A cross-tabulation summarizes combinations of categorical variables. For variables A and B, a cell may report a count, row percentage, column percentage, or total percentage. These answer different questions. Row percentages describe the distribution of B within each category of A; column percentages describe A within each category of B.

For example, if 30 of 100 online customers purchased a warranty, the online-row warranty rate is 30%. If 30 of 50 warranty purchasers were online, the online-column share is 60%. Confusing these denominators produces incorrect interpretations.

The chi-square statistic for testing independence in a contingency table is:

χ² = ∑ (Oᵢⱼ − Eᵢⱼ)² / Eᵢⱼ

where Oᵢⱼ is the observed count and Eᵢⱼ is the expected count under independence. For a table with row total Rᵢ, column total Cⱼ, and grand total N:

Eᵢⱼ = (Rᵢ × Cⱼ) / N

The approximation assumes independent observations and sufficiently large expected counts. A statistically significant result indicates evidence of association, not causation or practical importance.

8.3 Correlation and Association

Pearson’s sample correlation is:

r = [∑(xᵢ − x̄)(yᵢ − ȳ)] / √[∑(xᵢ − x̄)² × ∑(yᵢ − ȳ)²]

It measures the strength and direction of a linear association between two numeric variables, with −1 ≤ r ≤ 1. It is sensitive to outliers and can be misleading for nonlinear relationships. Spearman’s rank correlation is often more appropriate for monotonic relationships or ordinal data, though it also does not establish causation.

Always inspect a scatter plot or comparable diagnostic. Correlation can be driven by a third variable, reflect time trends, result from selection bias, or disappear within meaningful subgroups. Aggregated data can also produce a different relationship from individual-level data, a problem associated with ecological inference.

8.4 Segmentation

Segmentation divides observations into meaningful groups for comparison or action. Possible bases include customer value, behavior, geography, product use, risk, or lifecycle stage. A defensible segmentation has:

  • a clear purpose;
  • mutually interpretable rules;
  • adequate group sizes;
  • variables available at the time of decision;
  • stability or a plan for monitoring change.

A common value framework is monetary value, purchase frequency, and recency. Segments should not be treated as natural truths: they depend on definitions, scaling, time windows, and clustering choices. Compare segment sizes, averages, distributions, retention, and uncertainty rather than relying on a single label.

9. Diagnostic Reasoning and Communication

EDA is diagnostic when it asks why a pattern appears. Useful techniques include stratification by region or channel, before-and-after comparisons, time-series inspection, reconciliation to operational totals, sensitivity analysis, and examination of missingness by subgroup.

A strong analytical narrative distinguishes:

  • observation: what the data show;
  • explanation: a plausible reason;
  • implication: what decision may be affected;
  • limitation: what the data cannot establish.

For example, “customers receiving a discount had lower average margin” is an observation. It does not prove that discounts caused lower margin because discounts may have been targeted to already low-margin customers.

10. Worked Example: Retail Order Preparation

Consider an illustrative dataset of 10,000 online order lines. The business wants to compare profitability by sales channel.

Initial profile. The analyst finds 10,000 rows, 9,850 distinct order-line identifiers, 120 blank product codes, 85 dates in two formats, 40 negative quantities, and revenue recorded in both dollars and euros. A join to the customer table increases the row count to 12,400.

Diagnosis and preparation. First, the analyst confirms that order-line ID should be unique. The 150 repeated IDs are investigated; 100 are exact duplicates caused by an extract error, while 50 are legitimate line revisions. The extract duplicates are removed and revisions are retained with a status field. Negative quantities are found to represent returns, not errors, so they are retained and labeled as return transactions. Product codes are mapped through the current reference table. Dates are parsed using source-specific rules and checked against the transaction period. Currency is converted using documented transaction-date rates, and the original amount and currency are preserved.

The customer join is diagnosed as a many-to-many join because a historical customer-address table contains multiple records per customer. The analyst selects the address valid on the order date, reducing the result to the expected grain of one row per order line.

Exploration. Channel distributions are summarized using median order-line margin, return rate, and customer-level revenue. A scatter plot of discount percentage and margin identifies a nonlinear relationship and several high-value wholesale orders. Cross-tabulation shows that mobile orders have a higher return percentage, but the difference is concentrated in one product category. Stratification prevents the organization from applying a blanket mobile-channel policy.

Outcome. Management receives a validated channel comparison, a documented data-quality report, and a recommendation to investigate product sizing in the affected category. The analyst does not remove wholesale orders merely because they are extreme; instead, wholesale is reported as a distinct segment.

Learning points. Correct grain, business interpretation, reference data, time validity, and subgroup analysis are more important than mechanical cleaning alone.

11. Governance, Ethics, and Technology

Data preparation can affect people materially. Imputation may influence eligibility decisions; segmentation may create unfair targeting; and apparently harmless identifiers may enable re-identification when combined with other fields. Analysts should apply purpose limitation, data minimization, access control, retention rules, and applicable privacy law. Sensitive attributes should be handled under organizational policy, and fairness should be assessed when data-driven decisions affect protected or vulnerable groups.

Reproducibility requires versioned source extracts, code or documented procedures, data dictionaries, transformation logs, validation results, and clear ownership. Automated data-quality tools can monitor schema changes, null rates, ranges, and referential integrity. AI-assisted tools can suggest mappings, detect anomalies, or generate code, but their outputs require human review. They may reproduce historical bias, expose confidential data, or make undocumented transformations. Automation should support—not replace—domain validation and accountability.

12. Best Practices and Limitations

Best practices include defining the unit of analysis; profiling before cleaning; preserving raw data; using controlled vocabularies; validating joins; analyzing missingness by subgroup; treating outliers as hypotheses; separating exploratory from confirmatory claims; preventing leakage; and recording assumptions.

Limitations remain even after careful preparation. Data may not represent the target population, measurement definitions may change over time, missingness mechanisms may be unknowable, and observed associations may reflect confounding. EDA generates credible questions; it does not alone establish causal effects. Formal modeling, experimental design, or additional data may be required for causal decisions.

Chapter Summary

Data preparation converts heterogeneous raw data into a trustworthy analytical resource. The process begins with a clear business question, unit of analysis, and data profile. Missing values require attention to their causes and uncertainty; duplicates and inconsistencies require entity and business-rule validation; and outliers must be investigated rather than automatically deleted. Integration depends on keys, grain, definitions, and post-join checks. Transformations should preserve meaning and avoid data leakage.

Exploratory analytics uses distributions, robust summaries, cross-tabulations, correlations, segmentation, and diagnostic comparisons to reveal patterns and data problems. Means and standard deviations are useful under appropriate conditions, while medians and interquartile ranges are often more robust. Cross-tabulations require careful denominators, and correlation or statistical significance does not imply causation. Ethical governance, reproducibility, privacy, fairness, and transparent documentation are essential professional responsibilities.

Key Terms

Data preparation: Processes used to clean, integrate, transform, and organize data for analysis.

Exploratory data analysis: Investigation of data structure, patterns, relationships, and anomalies before or alongside formal modeling.

Unit of analysis: The entity represented by one analytical observation.

Data profiling: Systematic inspection of data structure, quality, distributions, and relationships.

Completeness: The extent to which required data values are present.

Validity: Conformity to defined formats, ranges, types, or business rules.

Duplicate: An exact or near-identical record that may unintentionally repeat an entity or event.

Entity resolution: The process of deciding whether records refer to the same real-world entity.

Outlier: An unusually distant observation that may be erroneous, rare, or meaningful.

Interquartile range: The difference between the third and first quartiles.

Imputation: Replacement or estimation of missing values.

Primary key: A field or combination of fields that uniquely identifies a record.

Foreign key: A field that references a key in another table.

Data leakage: Use of information unavailable at the time a prediction or decision would be made.

Cross-tabulation: A table summarizing combinations of categorical variables.

Correlation: A measure of association, commonly linear association for Pearson’s correlation.

Segmentation: Division of observations into meaningful groups for analysis or action.

Confounding: A situation in which an additional variable helps explain an observed association.

Reproducibility: The ability to recreate analytical results from documented data and procedures.

Data governance: Policies, roles, controls, and standards that manage data quality, security, use, and accountability.

Review Questions

Short Answer Questions

  1. Why must an analyst define the unit of analysis before joining datasets?
  2. Distinguish accuracy, completeness, validity, and consistency.
  3. What is the difference between an exact duplicate and a legitimate repeated transaction?
  4. Why is an outlier not automatically an error?
  5. What does a correlation coefficient measure, and what does it not prove?

Long Answer Questions

  1. Compare deletion, simple imputation, and multiple imputation for handling missing values. Discuss assumptions and risks.
  2. Explain how an analyst should validate a join between customer and transaction tables.
  3. Describe the interquartile-range approach to identifying potential outliers and discuss its limitations.
  4. Explain how row percentages and column percentages in a cross-tabulation answer different questions.
  5. Discuss how ethics, privacy, fairness, and reproducibility should influence data-preparation practice.

Analytical / Application Questions

  1. A transaction table contains one row per product line, while a customer table contains one row per customer. After joining them, the number of rows triples. Diagnose the likely cause and propose validation steps.
  2. A marketing analyst observes that discounted customers have lower profit. Identify at least three reasons this association may not represent a causal effect and specify additional analyses.
  3. A dataset contains missing income values concentrated among younger respondents and unusually high incomes in one region. Design an EDA and preparation plan that addresses missingness, outliers, subgroup differences, and reporting limitations.

Multiple Choice Questions with Answers

Question 1

Which action should normally occur before joining two datasets?

A. Delete all records with missing values

B. Establish each table’s grain and expected join relationship

C. Standardize every numeric variable to a z-score

D. Remove all observations identified as outliers

Correct Answer: B. Establish each table’s grain and expected join relationship

Question 2

For a numeric variable, the interquartile range is defined as:

A. The mean minus the median

B. The maximum minus the minimum

C. The third quartile minus the first quartile

D. The variance divided by the mean

Correct Answer: C. The third quartile minus the first quartile

Question 3

What is a major limitation of mean imputation?

A. It always increases sample size incorrectly

B. It can distort relationships and understate uncertainty

C. It can only be used for categorical variables

D. It necessarily removes all outliers

Correct Answer: B. It can distort relationships and understate uncertainty

Question 4

A many-to-many join most directly risks:

A. Reducing the number of columns to zero

B. Multiplying rows and double-counting measures

C. Converting dates into categories

D. Making every value missing

Correct Answer: B. Multiplying rows and double-counting measures

Question 5

Which statement about Pearson’s correlation is correct?

A. It proves that one variable causes another

B. It measures linear association and can be affected by outliers

C. It can only take positive values

D. It is appropriate only for nominal categories

Correct Answer: B. It measures linear association and can be affected by outliers

Question 6

If Q₁ = 20 and Q₃ = 32, what is the conventional upper exploratory fence?

A. 38

B. 44

C. 50

D. 68

Correct Answer: B. 44

Question 7

In a cross-tabulation, a row percentage describes:

A. The distribution of the row variable across all records

B. The distribution of the column variable within a row category

C. The percentage of missing values in the dataset

D. The correlation between the two variables

Correct Answer: B. The distribution of the column variable within a row category

Question 8

Which example best illustrates data leakage?

A. Using transaction date to derive transaction month

B. Using future cancellation status to predict current churn

C. Converting a text date into a date field

D. Grouping products by an approved category code

Correct Answer: B. Using future cancellation status to predict current churn

Question 9

Why might an analyst retain a valid extreme wholesale order as a separate segment?

A. Because all extreme values must be deleted

B. Because it may represent a meaningful population rather than an error

C. Because segmentation eliminates the need for validation

D. Because it guarantees a causal explanation

Correct Answer: B. Because it may represent a meaningful population rather than an error

Question 10

Which practice most supports reproducibility?

A. Overwriting raw values without a record

B. Reporting only the final chart

C. Maintaining source versions, transformation logic, and validation results

D. Removing all records that require judgment

Correct Answer: C. Maintaining source versions, transformation logic, and validation results

Fundamentals of Business Analytics
Chapter 6 of 15