First-Pass Review of an Unknown Dataset: Quality and Charts
Statistics & ExperimentsModel answerLast updated
Describe how you would inspect a dataset you have never seen, judge how trustworthy it is, and pick charts that help business stakeholders make a decision.
Scenario
A teammate hands you a tabular dataset you have never worked with. There is little documentation. Business stakeholders want useful insights and a few clear visuals within a short time.
Question
Describe, step by step, how you would:
- Get oriented in the dataset and understand what it contains.
- Judge whether the data can be trusted, and what you would do about problems you find.
- Decide which visualizations to build so that the main findings are clear to a non-technical audience.
Be concrete. Mention the specific checks you would run, how you would handle missing values, how the type of each variable and the business goal affect your choice of chart, and what caveats you would pass on to stakeholders.
Hints
Hint 1
Start by clarifying the decision the analysis supports and what a single row represents, before you run any code.
Hint 2
Treat quality as a checklist: completeness, uniqueness, validity, consistency, outliers and reconciliation against a trusted total. For missing values, ask why they are missing, not only how many.
Hint 3
Choose each chart from the variable types and the message (trend, comparison, distribution, relationship, composition), and check for segment mix effects before drawing conclusions.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
What a strong answer shows
A good answer is a repeatable workflow, not a list of commands. It is skeptical of the data, tied to a business decision, and aware of the audience.
Step 0: Scope the question
Before opening the data, clarify:
- Decision: what will the result change? "Why did repeat purchases fall last quarter?" needs a different analysis from "describe our customers."
- Grain: what does one row represent (order, order line, user-day, event)? A wrong assumption about grain causes double counting and is the most common source of wrong numbers.
- Provenance: which system produced it, how often it refreshes, who owns it, and what known issues exist.
- Key metrics and dimensions the stakeholders care about.
This keeps the exploration focused instead of producing dozens of charts nobody reads.
Step 1: Structural profiling
- Row and column counts, dtypes, and a sample of rows (head, tail, random, since files are often sorted).
- Check that the presumed key is unique. Duplicate keys mean the grain is not what you thought.
- Time coverage: min and max dates, gaps in daily counts, and a partial final day.
- Cardinality per column to separate IDs, low-cardinality categories, free text and constants.
- Label each column as continuous, count, nominal, ordinal, boolean, datetime, text or ID. This drives chart choice later.
import pandas as pd
def profile(df: pd.DataFrame) -> pd.DataFrame:
return pd.DataFrame({
"dtype": df.dtypes.astype(str),
"n_missing": df.isna().sum(),
"pct_missing": (df.isna().mean() * 100).round(2),
"n_unique": df.nunique(dropna=True),
}).sort_values("pct_missing", ascending=False)
print(df.shape, df["id"].is_unique)
print(profile(df))
print(df.describe(include="all").T)
Step 2: Data quality assessment
-
Completeness. Quantify nulls per column, then look for patterns by date, region, platform or source system (null rate over time is very revealing). Reason about the mechanism:
- MCAR: dropping rows is usually safe.
- MAR: explainable from other columns, so conditional or group-wise imputation can work.
- MNAR: missingness depends on the value itself (for example high earners skipping an income field), which biases naive analysis.
Also hunt for disguised nulls such as
0,-1,"N/A", empty strings and1970-01-01. Per column, choose to drop, impute, add a missing-indicator flag or exclude, and record the choice. -
Uniqueness. Exact duplicate rows and duplicate keys, often from join fan-out or retried loads.
-
Validity. Plausible ranges: no negative prices, sensible ages, rates between 0 and 1, no future timestamps, valid category codes.
-
Consistency. Same units and currency, same time zone, matching category spellings, and cross-field logic such as
ship_date >= order_dateortotal = qty * price. -
Outliers. Use IQR or z-scores and inspect the top N values. Decide whether each is an error (fix or remove), a real extreme (keep, use robust statistics) or a distinct population (segment it).
-
Reconciliation. Tie totals to a trusted source such as finance numbers or an existing dashboard. This is the best single sanity check and is often skipped.
-
Representativeness. Ask how the sample was collected. Selection or survivorship bias cannot be fixed by cleaning.
Keep a short data quality log and share it with the results.
Step 3: Univariate exploration
- Numeric: shape, skew, multimodality, tails. Compare mean with median and look at p1, p50, p99. Money-like variables are right-skewed, so use medians and log scales.
- Categorical: frequency table and long tail, grouping rare levels into "Other."
- Temporal: trend, seasonality (day of week, holidays), and structural breaks that may mark a pipeline or product change.
Step 4: Bivariate and multivariate exploration
Focus on relationships with the metric that matters.
- Numeric vs numeric: scatter (hexbin for large n), Pearson for linear and Spearman for monotonic relationships, and a correlation matrix to spot collinearity.
- Categorical vs numeric: group summaries with counts, box or violin plots. Always show n, since small groups give noisy extremes.
- Categorical vs categorical: crosstabs with row percentages.
- Over time by segment: small multiples.
- Confounding and Simpson's paradox. An overall drop may come from a shift in mix (for example more mobile traffic) and not from a change in underlying rates. Decompose into mix and rate effects.
- Correlation is not causation. Flag hypotheses that need an experiment.
Step 5: Choosing visualizations
Choose by variable type and message:
| Message | Variables | Chart |
|---|---|---|
| Trend | time + numeric | Line chart, annotate events |
| Compare groups | category + numeric | Sorted horizontal bars |
| Distribution | one numeric | Histogram or box plot, log scale if skewed |
| Relationship | numeric + numeric | Scatter or hexbin with trend line |
| Composition | parts of a whole | Stacked or 100% bars (avoid pies beyond about 4 slices) |
| Two categories | cat x cat | Heatmap |
| Process | ordered stages | Funnel or step-conversion bars |
| Many segments over time | time x category | Small multiples |
Design principles for stakeholders:
- One message per chart, with a title that states the takeaway ("Repeat rate fell 4 points in the mobile segment").
- Start bars at zero, label axes and units, show sample sizes, and show uncertainty where it matters.
- Avoid dual axes, 3D effects and rainbow palettes.
- Put 3 to 5 key visuals in the main story and keep the rest as an appendix.
Step 6: Communicate
Lead with the answer to the business question, then supporting evidence, then data caveats and recommended next steps (for example a follow-up experiment or a data fix). State confidence honestly.
Trade-offs and follow-ups
- 30% of a key column is null: investigate the mechanism first. If it is tied to a segment or time window, fix the pipeline or report that segment separately. Impute only if the missingness is explainable, run a sensitivity check with and without imputation, and never silently drop.
- Time pressure: do the grain, key uniqueness, null patterns and reconciliation checks first. They catch the most damaging errors.
- Very large data: profile on a stratified sample, then confirm key figures on the full set.
Common mistakes
- Charting before understanding the grain.
- Dropping nulls without checking for a pattern.
- Reporting means on skewed data.
- Ignoring segment mix and Simpson's paradox.
- Using chart types because they look impressive and not because they fit the message.
- Presenting results without caveats from the quality review.