DataLeaguebeta

Project

Penguins from Antarctica: types of variables and frequencies

From a first look at the table through frequencies and intervals to a contingency table. On real measurements of 344 penguins.

9 steps~45 min165 points in total

From 2007 to 2009, scientists at Palmer Station in Antarctica caught and measured 344 penguins of three species on three islands. In this project you will go through their data step by step, the way an analyst does on first meeting a new table: you will find out what it contains and what is missing, assign the variables to measurement scales, compute frequencies and proportions, group a continuous variable into intervals and use a contingency table to find out whether two categorical variables are related.

Each step is a separate task with a check and hints. The code steps already have the data and the results of the previous steps loaded, so a mistake in one step does not spoil the next ones.

Data

The file tucniaky.csv: semicolon separator, decimal point, an empty cell means a missing value. One row is one measured penguin. The column names are in Slovak and stay that way in the code.

columnmeaningunit or values
druhpenguin speciesAdelie, Chinstrap, Gentoo
ostrovisland where it was observedBiscoe, Dream, Torgersen
dlzka_zobaka_mmbill lengthmm
hlbka_zobaka_mmbill depth (height of the bill at its highest point)mm
dlzka_kridla_mmflipper lengthmm
hmotnost_gbody mass when caughtg
pohlaviesex, if it could be determinedsamec (male), samica (female)
rokseason of observation2007, 2008, 2009

Source: Palmer Penguins (Gorman, Williams and Fraser, 2014; Palmer Station Antarctica LTER), licence CC0. The column names and the values of sex are translated into Slovak, the other values are original.

Data

tucniaky.csv344 rows, 8 columns

Download CSV
First 5 rows of the file
druhostrovdlzka_zobaka_mmhlbka_zobaka_mmdlzka_kridla_mmhmotnost_gpohlavierok
AdelieTorgersen39.118.71813750samec2007
AdelieTorgersen39.517.41863800samica2007
AdelieTorgersen40.318.01953250samica2007
AdelieTorgersenNaNNaNNaNNaNNaN2007
AdelieTorgersen36.719.31933450samica2007

Steps

The steps build on each other. In code steps the data and the results of earlier steps are already prepared.

  1. Step 1

    A first look at the table

    code20 pts
    pandasloading datamissing values

    Load the file tucniaky.csv and find out how big the table is and how much of it is missing.

    1. Load the data into df. The column separator is a semicolon.
    2. Store the number of rows and columns in riadky (rows) and stlpce (columns).
    3. Store in chybajuce_bunky how many cells are missing in the whole table, and in riadky_s_chybou in how many rows at least one value is missing.
    Python loads when you first use the editorPackages:pandas

    The output appears after you run the code.

    Run the code and fix the errors until all checks pass.

  2. Step 2

    What scale the variables are on

    choice15 pts
    measurement scalestypes of variables

    This is the output of df.info() for the penguins:

     #   Column           Non-Null Count  Dtype
    ---  ------           --------------  -----
     0   druh             344 non-null    object
     1   ostrov           344 non-null    object
     2   dlzka_zobaka_mm  342 non-null    float64
     3   hlbka_zobaka_mm  342 non-null    float64
     4   dlzka_kridla_mm  342 non-null    float64
     5   hmotnost_g       342 non-null    float64
     6   pohlavie         333 non-null    object
     7   rok              344 non-null    int64
    

    Which statement about the variables is correct including its justification?

    Pick one option.
  3. Step 3

    Frequencies and proportions

    code20 pts
    pandasfrequenciesrelative frequency

    Find out how the penguins are distributed by island and sex. The table df is already loaded.

    1. Store the number of penguins on each island in pocty_ostrov.
    2. Store the proportions (numbers from 0 to 1) in podiely_ostrov.
    3. Store the same proportions in percent, rounded to one decimal place, in percenta_ostrov.
    4. Store the proportion of males (samec) and females (samica) among the penguins whose sex is known in podiely_pohlavie.
    Python loads when you first use the editorPackages:pandas

    The output appears after you run the code.

    Run the code and fix the errors until all checks pass.

  4. Step 4

    How many are female

    number10 pts
    relative frequencymissing values

    Based on the previous step: what percentage of the penguins with known sex are female? Enter it to one decimal place.

    %

    Both a decimal point and a decimal comma are accepted.

  5. Step 5

    Bill depth in intervals

    code25 pts
    pandasgrouping into intervalsSturges' rulehistogram

    Group the bill depth (hlbka_zobaka_mm) into intervals following the procedure from the lesson. The smallest value is 13.1 mm, the largest 21.5 mm.

    1. Store the number of filled-in values in n and the number of intervals by Sturges' rule in r.
    2. Store the interval width in h: the range divided by r, rounded up to tenths of a millimetre.
    3. Store the list of boundaries (hranice) starting at 13.0 mm (just below the minimum) for r intervals.
    4. Store the numbers of penguins in the intervals, sorted by interval, in pocetnosti, and the cumulative percentages in kumulativne_pct.
    5. Draw a histogram with the same boundaries.
    Python loads when you first use the editorPackages:pandasmatplotlib

    The output appears after you run the code.

    Run the code and fix the errors until all checks pass.

  6. Step 6

    Reading the cumulative frequency

    number10 pts
    cumulative frequencygrouping into intervals

    Based on the previous step: what percentage of penguins have a bill depth of at most 17.0 mm? Enter it to one decimal place.

    %

    Both a decimal point and a decimal comma are accepted.

  7. Step 7

    Island and sex in a contingency table

    code25 pts
    pandascontingency tableexpected frequencyresidual frequency

    Is a penguin's sex related to the island where it lives? Build a contingency table and compare the observed and expected frequencies.

    1. Store the observed frequencies in tabulka (island in rows, sex in columns, without totals).
    2. Store the conditional relative frequencies by rows (row proportions) in po_riadkoch.
    3. Store the expected frequencies, if sex were not related to island, in ocakavane.
    4. Store the residual frequencies (observed minus expected) in rezidua.
    Python loads when you first use the editorPackages:pandas

    The output appears after you run the code.

    Run the code and fix the errors until all checks pass.

  8. Step 8

    Is sex related to island?

    choice15 pts
    contingency tableinterpretationresidual frequency

    Based on the contingency table from the previous step: is a penguin's sex related to the island?

    ostrov (island)samec (male)samica (female)proportion of males
    Biscoe83800.509
    Dream62610.504
    Torgersen23240.489
    Pick one option.
  9. Step 9

    A short report on the data

    text25 pts
    interpretationsample and populationmissing values

    Write a short report (4 to 8 sentences) for a colleague who has not seen the data yet. Describe who the data capture, what is missing in them, at least two findings with specific numbers from this project, and what to watch out for when generalising.

    0 words, minimum 5050 words to go