DCubes
Python module

Foundations · Module 03

Python

Virtualenvs, scripts, files as data, pandas, and loading Postgres from Python. Practice only on your machine.

Beginner17 lessons~10 hours plus a demo

Data jobs are Python scripts in a virtualenv: read files, call an API, shape a DataFrame, write rows to Postgres. Notebooks are files you inspect — not the source of truth for a pipeline. This module teaches that spine after Linux and Docker.

You will install Python, use venv and pip, work with CSV and JSON, touch NumPy and pandas, talk to Postgres with psycopg, then generate random retail orders and load them. The site never runs Python for you.

Start here

Finish Linux and DockerGetting Started first so you have a terminal, ~/dcubes, and Compose. Then do this module’s Getting Started — we create ~/dcubes/python-lab and check python3.

  1. On-ramp

    Ready

    Your Python practice environment

    Install Python 3.11+ on Windows, macOS, or Linux. This site never runs Python — you will.

    40 min

  2. Lesson 1

    Ready

    Why Python for data and AI

    Where Python shows up in data work, and which skills this module will teach.

    20 min

  3. Lesson 2

    Ready

    REPL and scripts

    Use the interactive interpreter for tiny checks, and .py files for real work.

    25 min

  4. Lesson 3

    Ready

    Virtualenvs and pip

    Isolate project dependencies with venv, install packages, and freeze requirements.

    30 min

  5. Lesson 4

    Ready

    Types and collections

    Strings, numbers, booleans, and list/dict/tuple/set — the shapes data rows take in Python.

    30 min

  6. Lesson 5

    Ready

    Control flow and functions

    if/for/while and small def helpers — the spine of every data script.

    35 min

  7. Lesson 6

    Ready

    Errors and logging

    Catch failures on purpose and log what jobs did — print is not enough.

    30 min

  8. Lesson 7

    Ready

    Paths and text files

    Use pathlib to build paths, read and write text, and keep a clean lab layout.

    30 min

  9. Lesson 8

    Ready

    CSV and JSON

    Read and write tabular CSV and nested JSON with the standard library.

    35 min

  10. Lesson 9

    Ready

    HTTP and simple APIs

    Fetch JSON over HTTP with httpx, check status codes, and keep secrets in the environment.

    35 min

  11. Lesson 10

    Ready

    NumPy basics

    ndarrays, shape, dtype, and vectorized operations — the array mental model under pandas and ML.

    35 min

  12. Lesson 11

    Ready

    DataFrames

    Load CSV into pandas, inspect dtypes, filter rows, and handle simple missing values.

    40 min

  13. Lesson 12

    Ready

    Group, join, write

    groupby aggregates, simple merges, and writing results back to CSV.

    40 min

  14. Lesson 13

    Ready

    Postgres from Python

    Connect with psycopg, run parameterized SQL, and insert rows into a Compose Postgres.

    45 min

  15. Lesson 14

    Ready

    DataFrames and Postgres

    Move data between pandas and PostgreSQL with psycopg — load from a DataFrame, read query results back.

    40 min

  16. Lesson 15

    Ready

    Scripts, modules, and typing

    Import your own code, use if __name__, type hints, and a clean requirements.txt.

    35 min

  17. Lesson 16

    Ready

    Notebooks as files

    Run Jupyter in a venv, understand that .ipynb is JSON, and keep scripts as the source of truth.

    35 min

Demo