Profiling a Dataset Before You Trust It
Run a fast first-look profile of any dataset: shape, types, missing counts, distinct values and summary statistics that expose hidden problems early.
Welcome back!
Step 1 of 11Learn
The first five minutes
You receive a file called customers_final_v3.csv with 50,000 rows. Before you calculate anything, spend five minutes asking the data some blunt questions:
- How many rows and columns are there, and is that what you expected?
- What type did each column load as? Is a number column secretly text?
- How many values are missing in each column?
- How many distinct values does each column have?
- What are the smallest and largest values in each numeric and date column?
- What are the most common values in each text column?
This is profiling: a systematic first look that turns "the data seems fine" into a list of concrete suspicions. Profiling does not fix anything. It tells you where to look.
Profiling is fast because it is mechanical. In pandas, three calls cover most of it: df.info() for types and non-null counts, df.describe() for numeric summaries and df["col"].value_counts() for frequencies. In this course you will write small versions of these checks in plain Python, so you understand exactly what they compute and can reproduce them in any tool, from spreadsheets to SQL.
Step 2 of 11Learn
Reading a profile for red flags
Here is part of a profile for that customer file:
| column | type | missing | distinct | min | max |
|---|---|---|---|---|---|
| customer_id | text | 0 | 49,612 | ||
| age | number | 1,204 | 91 | -1 | 212 |
| zip | number | 0 | 8,733 | 501 | 99950 |
| signup_date | text | 0 | 2,950 | ||
| country | text | 37 | 14 |
Every row hides a question. customer_id has fewer distinct values than rows, so some customers appear more than once. age has impossible values at both ends; -1 is probably a code meaning "unknown". zip loaded as a number, so a code like 00501 became 501 and lost its leading zeros. signup_date is text, which means it was not recognized as a date, maybe because of mixed formats. country has 14 distinct values, but the company only sells in three countries, which points to spelling variants.
None of these is proven yet. A profile gives you hypotheses. Your next step is to look at actual example rows for each suspicion, such as all rows where age is above 110, before deciding what to do.
Step 3 of 11Practice · Select all that apply
A profile of an orders table shows the facts below. Which ones are red flags worth investigating? Select all that apply.
Select all that apply.
Step 4 of 11Learn
Distinct counts and value counts
Two of the most revealing numbers in a profile are the distinct count of each column and its value counts, the frequency of each value.
Distinct counts tell you what a column is. An ID column should have as many distinct values as rows. A yes/no field should have two, maybe three if blanks are allowed. A column with 2 distinct values out of 50,000 rows is a category; one with 49,000 is an identifier or free text.
Value counts tell you how a column is spelled. A country column might show:
| value | count |
|---|---|
| USA | 31,204 |
| United States | 9,877 |
| U.S. | 2,301 |
| us | 418 |
| Canada | 5,112 |
That is one country recorded four ways. If you grouped by this column as it is, the United States would be split into four smaller bars and Canada would wrongly look like the second biggest market.
Look at the tail of the value counts as well as the head. Rare values with a count of 1 or 2 are often typos ("Untied States"), test records ("TEST CUSTOMER") or values that slipped in from a different column.
Step 5 of 11Practice · Work it out
An ID column in a table of 10,000 rows has 9,874 distinct values. What is the minimum number of rows that must be duplicates of an ID that already appeared?
Step 6 of 11Practice · Code challenge · Python
Write count_missing(rows) that takes a list of dictionaries (one per row, all with the same keys) and returns a dictionary with the number of missing values per column. Count a value as missing if it is None, an empty string, or a string containing only spaces.
count_missing([{"a": 1, "b": ""}, {"a": None, "b": "x"}, {"a": 3, "b": " "}])count_missing([{"name": "Ann", "age": 30}])count_missing([{"x": 0}, {"x": None}])
Step 7 of 11Note
Step 8 of 11Learn
Summary statistics as smoke detectors
For numeric columns, a handful of summary statistics act like smoke detectors. They do not tell you what is burning, but they tell you to go look.
- Minimum and maximum: impossible values show up here first. Negative weights, ages over 120, dates in the future for past events.
- Mean versus median: if the mean income is $410,000 and the median is $52,000, a few huge values are pulling the mean up. That might be real (a few very rich customers) or an error (a value typed with three extra zeros).
- Suspicious round values: a spike of exactly 999, 9999, 0 or -1 often means a sentinel value, a code someone used to say "unknown". Treated as a real number, it corrupts every average.
- Counts of zero: is zero a real measurement or a placeholder? A rainfall of 0 mm is plausible; a body weight of 0 kg is not.
A quick histogram adds even more. A spike at a single value, a gap where data should be continuous, or two separate humps can all reveal mixed sources or coding problems. The goal is not to explain everything right away, only to write down what needs checking.
Step 9 of 11Explore
One huge value versus the mean
Illustrative: imagine n customers who each earn $52k, plus one extra customer whose income is on the x axis (in $ thousands). The curve is the mean of everyone. The median stays at $52k no matter how large that one value gets.
- Mean with that outlier
- 151 k $
- Median
- 52 k $
- Mean ÷ median
- 2.9
Step 10 of 11Practice · Sort into groups
From a profile of a hospital visits table, sort each observation into "Looks fine" or "Investigate".
Tap an item, then tap its group (or drag it there).
Step 11 of 11Practice · Choose one
A profile shows that the "income" column has a mean of $1.2 million and a median of $48,000. What is the most sensible next step?
Lesson complete!