Guided project: measured data, missingness and subgroup comparisons
On this page
An ecology teaching team wants a reproducible description of body mass and flipper length in the saved Palmer penguin observations. Analyze measurement completeness and species differences, while explaining why a pooled relationship is not a causal claim.
These observations were collected by Kristen Gorman and Palmer Station LTER; the simplified dataset is distributed through Horst, Hill and Gorman’s palmerpenguins package. The source register records the downloaded bytes and CC0 data terms. The table has 344 rows and eight fields. Measurements use millimetres and grams. The added snapshot-row identifier is a local audit ID, not a documented biological animal identifier.
Inspect the observation and missingness
Inspect types, category counts, years, missing values and exact duplicates. Define the analysis subset from the two required measurements, body mass and flipper length. Do not require observed sex merely because it is present in the table. Report how many rows a blanket drop of every missing field would exclude and why that would be a different inclusion rule.
Build the analysis tables
Retain a row identifier and separate observations lacking required measurements. For usable rows, verify positive physical measurements. Produce one species summary with support count, mean and median body mass, and mean flipper length. Produce a second summary by species and sex, retaining an explicit missing-sex group. Do not treat these tables as interchangeable population estimates.
Investigate and interpret
Create a scatterplot of flipper length and body mass with species identified and labelled units. Compare the pooled pattern with the within-species observations. Discuss whether sex composition, island and collection year might deserve additional analysis. Do not infer mechanisms merely from an association.
Calculate one group count and one mean independently from the selected rows. Explain which records contribute to each denominator. Contrast a mean of species means with a mean over all usable observations; choose the quantity that matches your stated question.
Deliver and extend
Export the retained and unresolved tables, two summaries, audit, plot and report. Acceptance evidence for the supplied snapshot includes 344 received observations, 342 with both measurements, two unresolved measurements and eleven missing sex values in the full table. Retain those eleven missing-sex states rather than fabricating labels.
For transfer, repeat a comparison within one sex where observed, report the changed support, and explain why it describes a restricted sample. The output remains descriptive of the recorded study observations. Sampling, biological and collection context matter before generalizing.
Begin the experiment
Run from the extracted experiment folder, or use the notebook’s first path-setup cell. Inspect the source before implementing the analysis.
from pathlib import Path
import pandas as pd
source = Path('data/teaching/penguins.csv')
records = pd.read_csv(source)
print(records.shape)
print(records.head())Check your work
Attempt the project first. Then compare with the complete worked solution. Preserve your own implementation and explain differences.