Find a course

Module 1: The Python Data ToolkitLesson 1 of 1212 min

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.

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.

  1. Define the question and how success will be measured
  2. Build and evaluate a model, if one is needed
  3. Communicate the results and recommendations
  4. Explore with summaries and charts to find patterns
  5. Collect or load the data
  6. 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:

LibraryWhat it doesTypical import
NumPyFast n-dimensional arrays and math on themimport numpy as np
pandasLabeled tables (DataFrames): loading, cleaning, grouping, joiningimport pandas as pd
MatplotlibThe foundational plotting libraryimport matplotlib.pyplot as plt
seabornStatistical charts on top of Matplotlibimport seaborn as sns
scikit-learnMachine learning: models, preprocessing, evaluationfrom sklearn... import ...
SciPyScientific computing and statistics routinesfrom 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.

The Python data stack: libraries built on top of each otherPython (the language)NumPy: fast arrayspandas: tablesSciPy: statisticsMatplotlib: plotsscikit-learn: modelsseaborn: statistical charts

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).

  1. Multiply a million numbers by 1.08 in one fast operation
  2. Load a CSV of sales and total revenue by region
  3. Draw a fully customized line chart for a report
  4. 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 .py modules with tests.

The goal is reproducibility: anyone, including you in six months, should get the same results from the same data and code.

Notebook cells run out of order: execution counts reveal hidden state[1]df = load("orders.csv")[4]df = df[df.total > 0][2]avg = df.total.mean()[3]df["total"] *= 1.08Top to bottom, the cellswere run 1, 4, 2, 3.Restart and Run Allgives a different result.

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.

Four types of analytical questionDescriptiveWhat happened?totals, trendsDiagnosticWhy did it happen?segments, comparisonsPredictiveWhat will happen?modelsPrescriptiveWhat should we do?predictions + costs

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?