The Data Science Workflow in Python
See how a data project moves from question to answer, why Python dominates the field, and which libraries handle each step from loading to modeling.
Welcome back!
Step 1 of 11Learn
A question worth $40,000
Maya works for a chain of bike-rental stations. Every summer, some stations run out of bikes by 9 a.m. while others sit full all day, and the company spends about $40,000 a season trucking bikes around. Her manager asks a simple question: which stations will run short tomorrow, and by how much?
Maya doesn't start by building a model. She starts with a spreadsheet export of 1.8 million rentals, opens it in Python, and discovers that 3% of rows have no station, timestamps come in two formats, and one station appears under three different names. Two days of cleaning later, a few lines of code show that weekday demand at downtown stations peaks at 8 a.m. and depends strongly on temperature and rain. A simple model built on those patterns predicts shortages well enough to cut the trucking bill by a third.
That's what data science looks like in practice. Most of the work is not the clever model at the end; it's getting trustworthy data into a usable shape and understanding it. Python is the most popular language for this work because it's readable, free, and backed by a mature ecosystem of libraries that handle each step.
This course teaches that workflow with the core tools: NumPy for fast numeric arrays, pandas for tables, Matplotlib and seaborn for charts, and scikit-learn for a first predictive model. You'll also write real Python in the browser to see what those libraries do under the hood.
Step 2 of 11Practice · Put in order
Put the typical steps of a data science project in order.
Drag the items, or use the arrow buttons, to put them in order.
- Define the question and how success will be measured
- Build and evaluate a model, if one is needed
- Communicate the results and recommendations
- Explore with summaries and charts to find patterns
- Collect or load the data
- Clean the data: fix types, missing values and duplicates
Step 3 of 11Learn
The Python data stack
Python itself is a general-purpose language. Its data science power comes from a stack of open-source libraries that build on each other:
| Library | What it does | Typical import |
|---|---|---|
| NumPy | Fast n-dimensional arrays and math on them | import numpy as np |
| pandas | Labeled tables (DataFrames): loading, cleaning, grouping, joining | import pandas as pd |
| Matplotlib | The foundational plotting library | import matplotlib.pyplot as plt |
| seaborn | Statistical charts on top of Matplotlib | import seaborn as sns |
| scikit-learn | Machine learning: models, preprocessing, evaluation | from sklearn... import ... |
| SciPy | Scientific computing and statistics routines | from scipy import stats |
The short aliases np, pd, plt and sns are universal conventions; you'll see them in nearly every tutorial and codebase.
These libraries are fast because their heavy lifting runs in compiled C code, while you write short, readable Python. pandas is built on NumPy arrays, seaborn on Matplotlib, and scikit-learn accepts NumPy arrays and pandas DataFrames directly, so data flows between them without conversion.
Most data scientists work in Jupyter notebooks: documents that mix code cells, their output (tables, charts) and explanatory text. Notebooks are ideal for exploration. Code that runs regularly in production is usually moved into ordinary .py files and tested.
Step 4 of 11Practice · Match the pairs
Match each task to the library most suited to it.
Tap an answer, then tap the place where it belongs (or drag it there).
- Multiply a million numbers by 1.08 in one fast operation
- Load a CSV of sales and total revenue by region
- Draw a fully customized line chart for a report
- Train a model that predicts house prices
Step 5 of 11Learn
Notebooks: powerful and easy to misuse
A Jupyter notebook lets you run code one cell at a time and see results immediately, which is perfect for poking at a new dataset. But notebooks have a famous trap: cells can run in any order, and the notebook remembers every variable from every cell you've run.
Imagine you load data in cell 1, filter out bad rows in cell 2, then go back and edit cell 1 to load a different file, but forget to rerun cell 2. Your analysis now mixes two states, and the numbers on screen can't be reproduced by running the notebook top to bottom. The little numbers beside each cell, such as [7], show the order cells actually ran in.
Habits that keep notebooks trustworthy:
- Restart and run all before trusting or sharing results. If it fails or the numbers change, something depended on hidden state.
- Keep the raw data untouched. Load it, then create cleaned copies; never overwrite the original file.
- Put imports and settings in the first cell.
- Record versions of key libraries, since results can change between releases.
- Move reusable logic into functions, and eventually into
.pymodules with tests.
The goal is reproducibility: anyone, including you in six months, should get the same results from the same data and code.
Step 6 of 11Practice · What would you do?
What would you do?
Leo's notebook shows that average order value rose 12%. When a colleague runs the same notebook from top to bottom, the result is 4%. What's the most likely explanation?
Step 7 of 11Learn
Asking a question data can answer
The most common reason data projects fail isn't bad code. It's a vague question. "Look at the sales data and find insights" can absorb weeks and produce a pile of charts nobody acts on.
A good analytical question is specific, measurable and tied to a decision:
- Vague: "How are our stations doing?"
- Better: "Which stations ran out of bikes before 9 a.m. on more than 20% of weekdays last summer?"
- Best: "...so that we can decide where to add 50 new docks next year."
The better versions tell you which data you need (rentals by station and time, plus capacity), what to compute (the share of weekdays with a stock-out), and what "done" looks like (a ranked list of stations).
It also helps to name the type of question, because each type calls for different methods:
- Descriptive: what happened? (totals, averages, trends)
- Diagnostic: why did it happen? (comparisons, segments, correlations, with care)
- Predictive: what will happen? (models such as regression)
- Prescriptive: what should we do? (combining predictions with costs and constraints)
Most business value comes from descriptive and diagnostic work done well. Prediction is powerful, but only after the simpler questions have trustworthy answers.
Step 8 of 11Practice · Sort into groups
Classify each question by type.
Tap an item, then tap its group (or drag it there).
Step 9 of 11Note
Step 10 of 11Practice · True or false
In most real data projects, cleaning and understanding the data takes more effort than building the final model.
Step 11 of 11Practice · Choose one
A notebook produces a chart that can't be recreated after restarting the kernel and running every cell in order. What principle has been broken?
Lesson complete!