Skip to content
Pricing

Python for Data Analysts: 10 Free Hands-on Lessons

Cleaning, reshaping, profiling, APIs, charts and automation in standard library Python, with the bridge to pandas.

10 lessonsAbout 20 hours4 beginner, 6 intermediateFree, runs offline

Cleaning, reshaping, profiling, APIs, charts and automation in standard library Python, with the bridge to pandas.

Complete beginner? If you have never run a Python file, go to phase 00, Start here first. It shows how to run a lesson and walks through your first Python script.

This phase uses only the Python standard library: csv, datetime, re, zoneinfo and plain dictionaries. No pandas. That is on purpose. Every step pandas does for you in one call, such as parsing dates, pivoting a table or grouping by week, is written out here by hand, so you see the decisions hidden inside those calls and can tell when a library made the wrong one. Each lesson runs on Python 3.9 or later with nothing to install.

  1. 1. Clean a messy CSV

    Which rows of this export can we trust, and what did we change to get there?

    Level 1: Beginner · about 2 hours

  2. 2. Reshape wide and long

    The data has one row per region and month. The manager wants one row per region. How do you move between the two without losing anything?

    Level 1: Beginner · about 2 hours

  3. 3. Dates, weeks and time zones

    How many people signed up each week over the new year, counted on the clock the team actually works on?

    Level 2: Intermediate · about 2 hours

  4. 4. Automate the weekly report

    Can the Monday KPI report write itself, with the same numbers every time it runs?

    Level 2: Intermediate · about 2 hours

  5. 5. Profile a table before you trust it

    Is this table fit for the board number?

    Level 1: Beginner · about 2 hours

  6. 6. Join two files and prove nothing was lost

    After the merge, are the totals still the totals?

    Level 1: Beginner · about 2 hours

  7. 7. APIs and JSON

    How many analyst roles did the feed return this week?

    Level 2: Intermediate · about 2 hours

  8. 8. More charts from scratch

    Histogram, scatter or line: which shows the answer, and how do bins and scales mislead?

    Level 2: Intermediate · about 2 hours

  9. 9. Data quality tests as code

    Would we have caught last week's broken load?

    Level 2: Intermediate · about 2 hours

  10. 10. From standard library to pandas

    Which pandas call does each function you wrote correspond to?

    Level 2: Intermediate · about 2 hours

By the end of the phase you will have built and tested each of these yourself, one per lesson:

  • Clean a messy CSV: parse_date: turns four different date formats into one, YYYY-MM-DD.
  • Reshape wide and long: pivot_wider: long to wide, with empty cells where a pair is missing, and an explicit choice for a pair that appears twice: raise an error (the default) or add the values up, never quietly keep one.
  • Dates, weeks and time zones: to_zone and to_pacific: show a UTC instant on the IST, PST or Pacific clock, with the US daylight saving rule written out by hand.
  • Automate the weekly report: latest_complete_week: finds the Monday of the last full week in the data.
  • Profile a table before you trust it: classify: one cell is empty, null text, an integer, a decimal, a date or text.
  • Join two files and prove nothing was lost: left_join and inner_join in plain Python, with fan-out and blank keys handled the way SQL does.
  • APIs and JSON: fetch_with_retry: one request, retried on 429 and 5xx with Retry-After or backoff, failing at once on anything else.
  • More charts from scratch: bin_edges and histogram: bins that never lose a value, with a clear rule for a value on an edge.
  • Data quality tests as code: Five row checks: check_not_null, check_unique, check_accepted_values, check_range, check_relationships.
  • From standard library to pandas: Six functions in the standard library, each with exactly the rules of one pandas call: read_typed, filter_rows, group_agg, sort_rows, drop_duplicates and value_counts.

Clone the course and run the first lesson's test. It fails until your exercise is right. You need only Python 3.9 or later.

git clone https://github.com/Ani19arya/analytics-from-scratch
cd analytics-from-scratch/phases/05-python-for-analysts/01-clean-a-messy-csv
python3 test_lesson.py
This phase on GitHub

Open roles on Real Analyst Jobs where this phase's skills come up, read daily from company career pages:

All 12 phases of Analytics from Scratch

Raj