pandas for traceable biological data wrangling

A pandas DataFrame is a labeled table. Start by inspecting column names, data types, and a small sample of rows before transforming anything. Keep one row per observational unit and one column per variable; this makes filters, group summaries, and merges auditable.


Boolean filtering selects rows that meet a condition, usually with df.loc[condition, columns]. Grouping followed by an explicit aggregation such as groupby(...).agg(...) summarizes observations without discarding the code that defines the summary. Missing values deserve an explicit choice: inspect them, then drop, impute, or retain them according to a documented scientific reason.


A merge combines tables by a key. Before merging, check that a supposed sample identifier is unique in the table where one record is expected; otherwise a many-to-many merge can duplicate measurements.


After each transformation, check row count, key uniqueness, and a few known records. Code is reproducible only when its assumptions about rows, variables, and keys are visible.

DataFrame df has columns plate and signal. Which expression returns the signal values from rows whose plate is B?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

A DataFrame df contains numeric column mass_mg. Write one pandas assignment that creates mass_g by converting mg to g, and state the value when mass_mg is 2750.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A table has one row per culture and columns medium and growth. Which pandas expression computes mean growth for each medium?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors