What data analysis is
Last updated
Data analysis is taking a question and some data, and coming back with an answer you can defend. In this lesson you'll meet the six steps every analysis goes through, the tools this course uses for each, and why doing it in code beats doing it by hand.
By the end of this lesson you can
- Name the six steps of an analysis, from getting data to sharing what you found
- Say what NumPy, pandas, matplotlib, seaborn and Jupyter are each for
- Explain why a fix made in code is better than a fix typed over the data
Questions first
Every store owner has data: receipts, a notebook of sales, a spreadsheet. Having data isn't the same as knowing something. Data analysis is taking a question and some data, and coming back with an answer you can defend.
The question comes first, because it decides everything else: which data you need, what "better" or "worse" means, and when you're done. "Look at the sales data" isn't a question. These are:
- Did the stores sell less rice in the rainy months?
- Which store's sales grew fastest this year, after taking out price rises?
- Did last month's promo bring in more customers, or just the same ones buying more?
All through this course you'll work on the same data: two years of sales from Tindahan, a small, made-up chain of sari-sari stores in five towns. It's made up so it can be messy in all the ways real data is, on purpose, without anyone's real details in it.
Six steps from question to answer
Most analyses go through the same six steps. Press Play, or step through one frame at a time.
The steps come from how statisticians and data scientists have described their work for decades, from John Tukey's Exploratory Data Analysis in 1977 to today's textbooks. Different books name them slightly differently. This course uses these six, and every lesson tells you which step it's about.
Why code, not only a spreadsheet
A spreadsheet is a fine tool, and you can do a lot of analysis in one. This course uses Python because code adds three things:
- It can be repeated. Next month's file arrives: run the same code again, instead of redoing every click.
- It can be checked. Every step is written down, so someone else (or you, in six months) can see exactly what was done.
- It can go bigger. A spreadsheet slows down at a few hundred thousand rows. Python handles millions.
Here's a notebook: Python code in cells, with the results right under each cell and notes in between. You'll learn how it works in the next lesson. For now, press Run all at the top. Then change one of the numbers in the list and run all again: every result updates.
-
Rice sold this week
Kilos of rice the Batangas store sold each day, Monday to Sunday.
-
-
-
The average in the second cell is the mean: add up the values and divide by how many there are. Written as a formula, for values to :
(said “x bar”) is the mean, is how many values there are, and means “add up”. For this week, :
The code says the same thing: sum(kilos) / len(kilos). You'll see formulas like this all through the course, always next to the code that computes them.
The tools, layer by layer
You won't write everything from scratch. Python has free, open-source tools for data, made by large communities and used everywhere from student theses to space agencies. Each one is built on the one below it.
You'll meet them in that order. This stage is about Jupyter, the notebook. Stage 2 is NumPy, Stages 3 to 5 are pandas, Stages 6 and 7 are charts, and Stage 8 is statistics.
Wrong way: fixing data by typing over it
Next week's sales came in, typed by hand. Run the first code cell. An average of 629 kilos a day, when the store usually sells about 45? Something's wrong. Look at the list: Thursday says 4100. Someone typed 41.00 and lost the decimal point. One wrong value is enough to drag the mean a long way:
The tempting fix is to go into the data and type over it: change 4100 to 41 and say nothing. That works today. But later nobody can tell the data was changed, why it was changed, or whether the fix was right. If the original file arrives again, the mistake comes back.
The better fix is the second code cell: the original stays as it arrived, and the change is made in code, with a comment saying what was wrong and how you know. Run it.
-
Next week's sales arrived, typed in by hand. Thursday looks odd.
-
-
Fix it in a cell, with a note saying why. The original stays as it was, and anyone can see what changed.
-
This is the first of many "wrong way" steps. In data analysis, most mistakes don't stop with an error message. The code runs and gives a wrong number. The habit this course builds is to stop and ask whether a number makes sense.
Which step is it?
Sort each task into the step it belongs to. Pick a step for each card, then check it.
0 of 7 placed right
Download each town’s rainfall from the weather service
Turn “₱1,250.00” into the number 1250
Count how many days are missing for each store
Draw weekly sales as a line, with typhoon weeks shaded
Work out whether the promo really raised sales, and how sure we can be
Write a one-page summary for the store owners
Merge two spellings of the same store into one
Check what you learned
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.
- Wickham, Tidy Data, Journal of Statistical Software 59(10), 2014: why cleaning takes so much of an analysis, and a way to organise it
- Jupyter: What is a notebook?: notebooks mix code, results and text
- NumPy: What is NumPy?: arrays, and why they're faster than lists
- pandas: Package overview: tables with labelled columns, built on NumPy
- seaborn: An introduction to seaborn: statistical charts built on matplotlib