Exploratory and applied analysis · lesson 3 of 11
Parts in this lesson
ADEFINITIONS = {"term": "meaning"}definitions kept next to the code that uses them

From a vague question to a measure

Last updated

“Is the business doing well?” is the question owners really ask, and no table can answer it as it stands. Doing well compared with what? Measured how? Over which months? In this lesson you'll break a vague question down into exact measures, define each one so precisely that two people would compute the same number, and see what happens when two notebooks use the same words for different things.

By the end of this lesson you can

  • Break a vague question into answerable ones
  • Define a measure exactly: what counts, the unit and the time window
  • Write definitions down where the analysis can use them

Vague and answerable questions

A question is answerable when you know what number would answer it, and from which data. "Is the business doing well?" isn't yet: "well" could mean growing, profitable, better than last year, better than other stores, or keeping its customers. Break it down one rung at a time:

From vague to exact0 of 5 rungs

“Is the business doing well?”

Each rung narrows the question until a number can answer it. Three measures, each answerable from the data, together say far more than any one "doing well" score could. And each can be checked again next month.

Defining a measure exactly

A measure is defined when two people, working separately, would get the same number. That takes three things:

  • What counts. Does a sale include refunds? Card discounts? The GCash fee? Is a "customer" a person, a card or a receipt?
  • The unit. Pesos or kilos? Per store, per day, per receipt, per 1,000 residents (9.4)? Nominal or real pesos (9.5)?
  • The time window. Calendar months, weeks from Monday or Sunday, the last 30 days, or the last 6 calendar months?

"Regular customer" shows how much this matters. Run the first cell.

measures.ipynb

Of the 331 card holders who bought in the second half of 2024, 244 bought in at least 3 of the 6 months, and 216 visited at least 12 times. Both are sensible definitions of "regular". They differ by 28 people, about one in twelve, and they pick out different people. A report saying "we have 244 regulars" and another saying "216" would both be right, and nobody reading them could tell why they disagree.

Wrong way: two kinds of “monthly sales”

Two family members each keep a notebook on the stores. Both chart "monthly sales". For October 2024 at Rosario, one says ₱41,498 and the other ₱46,109. Run the cell to find the rows where they disagree most.

measures.ipynb
  • Notebook A counts every peso taken in the calendar month.
  • Notebook B takes the average day open, times 30, "so months of different lengths compare fairly".

Both sound reasonable, and in most months they're close. But in October 2024, when Rosario was closed for 4 days, they disagree by 11.1%, and in every February by about 7%. Each family member has a different story about how October went, from the same data.

The check: when two numbers that should match don't, compare the definitions before the arithmetic. Then agree on one definition, write it down (step 4), and give the other measure a different name: here, "sales a day open" is a useful measure in its own right; it just isn't "monthly sales".

Writing definitions down

A definition only helps if it's written where everyone uses it. Keep a data dictionary: a short list of every term and measure, what it means, and where it comes from. Put it in the project's README, or at the top of the notebook as code, as the second cell in step 2 does with DEFINITIONS: a dictionary from term to meaning.

Good definitions:

  • Say what counts and what doesn't. "All pesos taken in a calendar month … Not adjusted for days closed."
  • Name the source. "From data/clean/books.csv."
  • Are dated when they change. If "regular customer" changes in March, numbers before and after can't be compared without saying so.

The definitions become part of the answer: a report says "regular customers (card holders who bought in at least 3 of the last 6 months) rose from … to …", so a reader knows exactly what rose.

Check what you learned

Which question is answerable from the Tindahan books as it stands?
Two analysts report different numbers of “active customers”. What should you check first?

Sources

Every example on this page was run with Python 3.14, and its output and error messages are copied from it. These pages cover the same ground in more depth.

All sources for Simple Data Analysis