These are the notes for Data Analytics with Python, episode 1. This course starts from absolute zero and goes to expert level, and every term is explained in plain words the first time it appears (the Glossary at the end collects them all). In this episode you will learn what data and data analytics are, why nobody can find answers by staring at thousands of rows, what an insight, a data-driven decision and a stakeholder are, the four kinds of analytics, the five data jobs, and the six-step workflow every analysis follows. You will also run your first analysis in Python. Every program below runs as-is in the SyntaxPilot compiler, and every output shown is the real output from Python 3.13.
Don't worry if some Python looks new. Episodes 4 to 7 teach every line of Python from scratch. For now, read the code like English and focus on the ideas.
The problem: Ramesh's chai stall
Ramesh runs a chai stall outside Andheri station in Mumbai. Every evening he writes in a notebook how many cups he sold: Monday 320, Tuesday 180, and so on. Some days sales drop badly and he doesn't know why, so he guesses: "maybe people are bored of chai, let me change the recipe". If the guess is wrong, he changes the recipe for nothing.
The answer is already in his notebook. He just doesn't know how to get it out. Getting answers out of data is what this course is about.
Data, analytics and data analytics
| Term | Plain meaning | Example from the chai stall |
|---|---|---|
| Data | Recorded facts: numbers, words, dates | "Tuesday, rainy, 180 cups" |
| Analytics | Examining data carefully to find answers to questions | Comparing sunny and rainy days |
| Data analytics | Turning data into answers, and answers into decisions | "Rain cuts sales, so offer delivery on rainy days" |
| Data analyst | The person whose job is data analytics | Someone Ramesh hires to study his notebooks |
Scale it up: why staring at rows fails
Ramesh opens four stalls (Andheri, Bandra, Dadar, Thane) and keeps writing for a whole year: 4 × 365 = 1,460 rows. This program makes up a year of sales like that, one line per stall per day:
import random
random.seed(7)
stalls = ["Andheri", "Bandra", "Dadar", "Thane"]
for day in range(1, 366):
for stall in stalls:
print("Day", day, stall, random.randint(80, 400), "cups")
Output (the last 3 of 1,460 lines):
Day 365 Bandra 83 cups
Day 365 Dadar 272 cups
Day 365 Thane 303 cups
random.seed(7)makes the "random" numbers the same every time you run it, so your output matches this page.random.randint(80, 400)picks a whole number between 80 and 400.
Now try to answer: which stall is worst? Do rainy days hurt? You can't, just by looking. Two reasons:
- Human eyes and memory can't hold more than a handful of numbers at once.
- Without a question, you don't know what to look for.
The fix, and the heart of analytics: ask one clear question, then let the computer summarise the rows into a few numbers you can read (totals, averages, a chart).
Insight, data-driven decision, stakeholder
| Term | Plain meaning | Example |
|---|---|---|
| Insight | A useful finding you didn't know before | "Rainy days sell about 45% fewer cups" |
| Data-driven decision | A choice made because of evidence, not a gut feeling | "Start a delivery service on rainy days" |
| Stakeholder | Anyone who cares about the result or will act on it | Ramesh, his staff, the bank that lent him money |
Gut feeling vs data-driven, for the same problem:
| Gut feeling | Data-driven |
|---|---|
| Sales fell on Tuesday. | Question: do rainy days hurt sales? |
| Maybe people are bored of chai? | Sunny days: 315 cups on average |
| Change the recipe. | Rainy days: 172 cups on average |
| Sales still fall on rainy days: money wasted. | Offer delivery on rainy days. |
Analysts work for stakeholders, so the first job in any analysis is to understand what they need.
The four kinds of analytics
A visit to the doctor explains them. They are often drawn as a ladder (Gartner's "analytic ascendancy model"): each step answers a harder question and adds more value.
| Doctor | Kind of analytics | Question it answers | Chai stall example |
|---|---|---|---|
| "You have 102 °F fever" | Descriptive | What happened? | "Bandra sold 98,000 cups last year" (a report) |
| "It's an infection" | Diagnostic | Why did it happen? | "July dropped because of the monsoon" |
| "You'll be fine in 3 days" | Predictive | What will happen? | "Next July will drop again" (a forecast) |
| "Take this, rest 2 days" | Prescriptive | What should we do? | "Stock less milk on rainy days" |
Most day-to-day analyst work is descriptive and diagnostic. This course starts there and climbs the whole ladder (forecasting and regression come later).
The five data jobs
A restaurant kitchen explains who does what:
| Restaurant | Data job | What they do | Typical tools |
|---|---|---|---|
| Supplier who brings vegetables every morning | Data engineer | Builds pipelines: automatic systems that move data from apps and machines into one store | Python, SQL, cloud services |
| Prep cook who washes and chops | Analytics engineer | Turns raw data into clean, tested, well-named tables anyone can use | SQL, dbt |
| Chef who cooks today's orders | Data analyst | Takes a business question, analyses data, serves an answer | Excel, SQL, Python, charts |
| (front of house) | BI analyst | BI = business intelligence. Builds dashboards: screens of charts that update by themselves | Power BI, Tableau |
| Recipe researcher inventing new dishes | Data scientist | Uses statistics and machine learning (programs that learn patterns from data) to build models that predict | Python, statistics, ML libraries |
Job titles overlap a lot between companies. This course trains you for the data analyst role with Python, and gives you a strong base for the others.
The analysis workflow: 6 steps
This version of the workflow comes from Google's Data Analytics Certificate:
| Step | What you do | Chai stall |
|---|---|---|
| 1. Ask | Agree on the exact question with stakeholders | "Do rainy days hurt sales?" |
| 2. Prepare | Find and collect the data that can answer it | One week of the Andheri notebook |
| 3. Process | Clean it: fix mistakes, gaps and duplicates | Remove Saturday's "N/A" |
| 4. Analyse | Calculate and compare to find patterns | Average cups per weather |
| 5. Share | Show the result: charts and a clear story | A bar chart: sunny vs rainy |
| 6. Act | Stakeholders make a decision | Delivery on rainy days |
Ask → Prepare → Process → Analyse → Share → Act
Your first analysis in Python
Steps 1 and 2: ask and prepare
# ASK: do rainy days hurt chai sales?
week = [("Mon", "sunny", 320), ("Tue", "rainy", 180),
("Wed", "sunny", 305), ("Thu", "rainy", 165),
("Fri", "sunny", 340), ("Sat", "rainy", "N/A"),
("Sun", "sunny", 298)]
- A line starting with
#is a comment: a note for humans that Python ignores. We write the question there. weekis a list: many values kept in order, like a shopping list. Each entry holds a day, the weather and the cups sold.- Ramesh was sick on Saturday, so the notebook says
"N/A"(not available).
The obvious attempt: add it all up
total = 0
for day, weather, cups in week:
total = total + cups
print("Cups this week:", total)
A for loop means "repeat this for every item in the list". Real output:
Traceback (most recent call last):
File "main.py", line 8, in <module>
total = total + cups
~~~~~~^~~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Why: int means a whole number and str means text. Python can't add the text "N/A" to a number. Real data is messy (typos, gaps, missing days); analysts call it dirty data. That is why step 3, process (cleaning), exists, and why analysts often say cleaning takes most of their time.
Steps 3, 4 and 5: process, analyse, share
# ASK: do rainy days hurt chai sales?
week = [("Mon", "sunny", 320), ("Tue", "rainy", 180),
("Wed", "sunny", 305), ("Thu", "rainy", 165),
("Fri", "sunny", 340), ("Sat", "rainy", "N/A"),
("Sun", "sunny", 298)]
# PROCESS: keep only real numbers
clean = [row for row in week if row[2] != "N/A"]
# ANALYSE: average cups for each kind of weather
for w in ["sunny", "rainy"]:
cups = [c for d, wt, c in clean if wt == w]
avg = sum(cups) // len(cups)
# SHARE: a tiny text chart
print(w.ljust(6), "#" * (avg // 20), avg)
Output:
sunny ############### 315
rainy ######## 172
row[2]is the third value of a row (Python counts from 0), the cups.- The average (mean) is the total divided by how many values there are.
//divides and drops the decimals, so 315.75 becomes 315. "#" * (avg // 20)repeats#once for every 20 cups: a tiny text bar chart.
Insight: sunny days average 315.75 cups and rainy days 172.5, so rain cuts sales by (315.75 − 172.5) / 315.75 ≈ 45%. One week is a small sample; a real analyst would check a whole year before betting money on it, but the method is the same.
Step 6: act
With evidence, Ramesh can decide: deliver to nearby offices on rainy days, make less chai on rainy days to waste less milk, add a monsoon combo (chai + pakora). You just ran the whole workflow: ask → prepare → process → analyse → share → act.
Common mistakes (with the real error messages)
| Mistake | Real message | Why | Fix |
|---|---|---|---|
Adding a column that contains text like "N/A" |
TypeError: unsupported operand type(s) for +: 'int' and 'str' |
Dirty data: text hiding in a number column | Clean first (step 3) |
Averaging a group with no rows: sum([]) // len([]) |
ZeroDivisionError: integer division or modulo by zero |
e.g. asking for "stormy" days when there were none | Check len(cups) > 0 first |
| Making charts before asking a question | (no error: just hours of charts and no answer) | You don't know what to look for | Write the question down first |
| Comparing totals when some days are missing | (no error: a wrong conclusion) | A stall with fewer recorded days looks worse | Compare averages, and report how many days each covers |
Mini project: which stall had the best week?
Three stalls, one week each. None means "no number recorded".
# Mini project: which stall had the best week?
sales = {
"Andheri": [320, 180, 305, 165, 340, None, 298],
"Bandra": [280, 150, 290, 140, 310, 300, 260],
"Thane": [210, 205, 230, 190, 250, 270, None],
}
averages = {}
for stall, days in sales.items():
clean = [c for c in days if c is not None] # PROCESS
averages[stall] = sum(clean) / len(clean) # ANALYSE
print(f"{stall:8} total={sum(clean):5} days={len(clean)} avg={averages[stall]:.1f}")
best = max(averages, key=averages.get)
print("Best average:", best)
Output:
Andheri total= 1608 days=6 avg=268.0
Bandra total= 1730 days=7 avg=247.1
Thane total= 1355 days=6 avg=225.8
Best average: Andheri
Notice: Bandra has the highest total, but Andheri has the highest average, because Bandra had one more recorded day. Which one is "best" depends on the question you asked in step 1. That's why step 1 matters.
Practice
1. Label each question as descriptive, diagnostic, predictive or prescriptive: (a) "How many cups did Thane sell in March?" (b) "How many cups will Thane sell next March?" (c) "Why did Thane sell less in March than February?" (d) "Should Thane open an hour earlier?"
Solution
(a) descriptive, (b) predictive, (c) diagnostic, (d) prescriptive.
2. Add a third weather, "cloudy", to the analysis and handle a weather with no rows without crashing.
Solution
week = [("Mon", "sunny", 320), ("Tue", "rainy", 180),
("Wed", "cloudy", 250), ("Thu", "rainy", 165),
("Fri", "sunny", 340), ("Sat", "rainy", "N/A"),
("Sun", "cloudy", 262)]
clean = [row for row in week if row[2] != "N/A"]
for w in ["sunny", "cloudy", "rainy"]:
cups = [c for d, wt, c in clean if wt == w]
if len(cups) == 0:
print(w, "no data")
continue
avg = sum(cups) // len(cups)
print(w.ljust(6), "#" * (avg // 20), avg)
Output:
sunny ################ 330
cloudy ############ 256
rainy ######## 172
3. Which of the six workflow steps does each action belong to? (a) Removing duplicate bills. (b) Meeting the owner to agree on the question. (c) Making a bar chart for the owner. (d) Downloading last year's sales file.
Solution
(a) Process, (b) Ask, (c) Share, (d) Prepare.
4. Write three questions you could answer with your own data (phone bill, UPI history, exam marks) and label each with its kind of analytics.
Sample answer
"How much did I spend on food last month?" (descriptive). "Why was October's spend higher?" (diagnostic). "How much will I spend in December?" (predictive).
Quick quiz
Ramesh asks: "Why did Bandra sell fewer cups in July than in June?" Which kind of analytics is that?
A. Descriptive B. Diagnostic C. Predictive D. Prescriptive
Answer
B. Diagnostic. The question asks why something happened, so we're looking for a cause, like a doctor's diagnosis.
Interview questions
- What does a data analyst do? Takes a business question, collects and cleans the right data, analyses it, and communicates the answer so stakeholders can decide.
- Data analyst vs data scientist? Analysts mostly answer "what happened and why" (descriptive and diagnostic) for business questions; data scientists more often build predictive models with statistics and machine learning. Titles overlap between companies.
- Explain the four kinds of analytics with an example. Descriptive (what happened), diagnostic (why), predictive (what will happen), prescriptive (what should we do); use any example such as the doctor or the chai stall.
- Walk me through your analysis process. Ask, prepare, process, analyse, share, act, and say what you do in each.
- Why is data cleaning important? Dirty data either crashes your code (like the
TypeError) or, worse, silently gives wrong answers. - Who are stakeholders, and why do they matter? The people who care about or act on the result; the question, the level of detail and the format of the answer all depend on them.
Glossary
| Term | Meaning | Example |
|---|---|---|
| Data | Recorded facts: numbers, words, dates | "Tue, rainy, 180 cups" |
| Analytics | Examining data to find answers | Comparing sunny and rainy days |
| Data analytics | Turning data into answers, then decisions | "Rain cuts sales by ~45%, so deliver on rainy days" |
| Data analyst | A person who answers business questions with data | Studies Ramesh's notebooks |
| Data scientist | Builds models that predict, using statistics and machine learning | Forecasts next month's sales |
| Data engineer | Builds pipelines that move data into one store | Sends every stall's billing data to one database each night |
| Pipeline | An automatic system that moves data from place to place | Billing app → central store, every night |
| Analytics engineer | Turns raw data into clean, tested, ready-to-use tables | A clean daily_sales table |
| BI analyst | Builds dashboards and regular reports (BI = business intelligence) | A morning sales dashboard |
| Dashboard | A screen of charts that updates by itself | Today's cups per stall |
| Machine learning (ML) | Programs that learn patterns from data | A model that predicts tomorrow's sales |
| Descriptive analytics | Answers "what happened?" | "Bandra sold 98,000 cups last year" |
| Diagnostic analytics | Answers "why did it happen?" | "July fell because of the monsoon" |
| Predictive analytics | Answers "what will happen?" | "Next July will fall too" |
| Prescriptive analytics | Answers "what should we do?" | "Stock less milk on rainy days" |
| Insight | A useful finding you didn't know before | "Rainy days sell ~45% fewer cups" |
| Data-driven decision | A choice based on evidence, not a gut feeling | Starting delivery because the numbers show rain hurts |
| Stakeholder | Anyone who cares about or acts on the result | Ramesh, his staff, his bank |
| Analysis workflow | The steps every analysis follows: ask, prepare, process, analyse, share, act | This episode's chai analysis |
| Ask | Step 1: agree on the exact question | "Do rainy days hurt sales?" |
| Prepare | Step 2: find and collect the right data | One week of the notebook |
| Process | Step 3: clean the data | Removing "N/A" |
| Analyse | Step 4: calculate and compare | Average per weather |
| Share | Step 5: present the result | A bar chart |
| Act | Step 6: decide and do something | Rainy-day delivery |
| Dirty data | Data with mistakes, gaps or wrong types | "N/A" in a number column |
| Comment | A # line for humans; Python ignores it |
# ASK: ... |
| List | Many values kept in order | ["sunny", "rainy"] |
| for loop | Repeat a block for every item | for w in ["sunny", "rainy"]: |
| int / str | A whole number / text | 180 / "N/A" |
| Average (mean) | Total divided by how many values | (320 + 305 + 340 + 298) / 4 = 315.75 |
| TypeError | Python's error for an operation on the wrong type | int + str |
| ZeroDivisionError | Python's error for dividing by zero | sum([]) // len([]) |
Summary
- Data is recorded facts; data analytics turns data into answers and decisions; a data analyst does that job.
- Nobody can read 1,460 rows by eye: ask one question, then let the computer summarise.
- An insight leads to a data-driven decision for the stakeholders.
- Four kinds of analytics: descriptive (what happened), diagnostic (why), predictive (what will happen), prescriptive (what to do).
- Five data jobs: data engineer, analytics engineer, data analyst, BI analyst, data scientist.
- Every analysis: Ask → Prepare → Process → Analyse → Share → Act. Cleaning (process) matters because real data is dirty.
- Next episode: data, datasets and the types of data.