Module 3 · Data, Variables, Samples, and Measurement Lesson 21 of 120

Observations, Entities, Variables, and Datasets

Three payment rows are not three customers.

2:38 clip1:08:38–1:11:17 in the full courseWatch on YouTube

Transcript

24 sentences · select one to jump there

Check your understanding

Should the second C1 row be removed as a duplicate?

Choose one answer

Code lab

Run it yourself

The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.

021-observations-entities-variables-and-datasets.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 021 of 120
 * Observations, Entities, Variables, and Datasets
 * Module 03: Data, Variables, Samples, and Measurement
 *
 * Scenario: Three payment rows are not three customers
 * Rule:     observation ≠ entity ≠ variable
 *
 * Try it:   Should the second C1 row be removed as a duplicate?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/data-variables-samples-and-measurement/observations-entities-variables-and-datasets/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson021() {
  const rows = [
    {payment: "P1", customer: "C1", amount: 20},
    {payment: "P2", customer: "C1", amount: 30},
    {payment: "P3", customer: "C2", amount: 50}
  ];
  const result = {rows: rows.length,
    customers: new Set(rows.map(r => r.customer)).size};
  return result;
}

export const checkedResult = {"rows":3,"customers":2};

// Run this file directly: npx tsx lessons/03-data-variables-samples-and-measurement/021-observations-entities-variables-and-datasets.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson021(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "rows": 3,
  "customers": 2
}

Prefer your own machine? Every file is in the course repository · open it in Codespaces.

Lesson notes

The rule

observation ≠ entity ≠ variable