Skip to content
Learn Python with BNHR

Module 4 · Beginner

Summarize and combine

Module 4 of Arrays & DataFrames: groups, values within groups, survey weights, long and wide tables, and joins that neither lose nor multiply rows. Its sections, its notebooks to read on the web, and the companion's solutions and explanations.

Module 4Level Beginner
On this page
  1. Overview
  2. What you do
  3. The module’s notebooks
  4. Certification and support

The questions people ask of a survey are about groups: the yield of rice in each province, each crop’s share of the land, how many farm households the survey stands for. This module answers them with groupby, then with survey weights, and shows how far an unweighted mean can be from the right answer. It reshapes tables between long and wide, and joins the survey to PSA’s code list on the code, never the name, checking that no row is lost or doubled.

  1. Group and aggregate
  2. Within groups: transform, shares, ranks, running totals
  3. Survey weights: weighted means, totals and shares
  4. Tidy data: pivot, melt, crosstab
  5. Joins and concatenation: keys, validate=, indicator=

The notebooks are in your course folder; here you can read them without running anything. For reference in any module: primer: marimo and the python this course assumes and primer: pandas 2 to 3 and glossary.

Saved in this browser only

Certification and support

We offer additional resources, certificates, ongoing support, and other perks to those who join our instructor-led training.

Join an upcoming training to take this as an instructor-led course, or contact us to arrange one for your team or organization.

Something new

Identify results
LayerExplore a module
ModuleFunctions
AboutModule 5 of Python Essentials: parameters, return values and defaults, scope, sorting with a key, lambda, map and filter, and reading a class. Its sections, its notebooks to read on the web, and the companion's solutions and explanations.
CoursePython Essentials, free