Skip to content
Learn Python with BNHR

Module 4 · Intermediate

Edit rules and duplicates

Module 4 of Python for Survey Statistics: editing and cleaning a survey's data: frequency tables against the codebook, cross-item rules, specifications that edit with a log, and duplicates by key and by a stated definition. Its sections, its notebooks to read on the web, and the companion's solutions and explanations.

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

This module edits and cleans the survey’s data. It checks coded items against the codebook’s lists in frequency tables, writes the cross-item rules the codebook states (a boat’s tonnage from its length, beam and depth; a unit’s scale from its boats), then writes the edit rules as specifications: a table of rules, each of which flags, sets a value, draws one at random with a seed, or refers the case to a person, applied with an edit log so every change can be read and run again. The worked examples are a blank that a rule can fill from another table, and a code outside its list replaced by a draw a rerun repeats.

The last section finds duplicates by key and by a stated definition (a registered boat under two units, an area in two strata), and lists what goes to a person to check by hand.

  1. Frequency tables against the codebook's valid codes
  2. Range and cross-item consistency rules
  3. Rules as data: a specification table run to a failure report
  4. Specifications that edit: a value set, a code drawn at random, a case referred
  5. Duplicates by key and by a stated definition; the referral list

The notebooks are in your course folder; here you can read them without running anything. For reference in any module: primer: from r to python and primer: survey sampling in one page and glossary.

Quizzes

The quizzes are on BNHR Quizzes and count toward nothing. Learning on your own, a quiz opens as the self-paced one; while a training runs, it asks which training you are in.

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
ModuleValues and names
AboutModule 2 of Python Essentials: numbers, text and true/false, names for them, f-strings and formats, and reading an error message. Its sections, its notebooks to read on the web, and the companion's solutions and explanations.
CoursePython Essentials, free