E ExamMaster

Data Science · Data Science Core

Where tables live

In Data Science because the shop sheet is usually a slice of a larger store — you pull the week you need rather than dumping every table.

Rao's eight-row week did not live alone. The shop also keeps inventory (one row per item on one day) and supplier invoices (one row per bill). A warehouse, in the sense this lesson needs, is just 'the place those tables live'. You slice the customer week out of it. This is not a NoSQL or Spark course.

  • Data Science
  • Medium level
  • 4 concepts

1Tables live in a store

The eight-row sheet you have been using is a working copy on the laptop. The durable copy sits with the other shop tables. customers_week is one customer in one week — Anu this week is one row. inventory is one item on one day — a bag of rice on Tuesday. invoices is one supplier bill. 'Warehouse' in this lesson is just a name for that store: the place the tables live. It is not a product, not Spark, and not a cluster you must build first.

Data science still starts with a question. The store is where you go to get the rows. You do not analyse every table because it exists. Inventory can wait until a question names it.

Figure. Three tables live in the shop store. customers_week is the one this course has been reading. inventory and invoices stay in the store until a question names them.

What lives in Rao's store
tableone row is
customers_weekone customer in one week
inventoryone SKU on one day
invoicesone supplier bill

Coding lab. Three tables in the store runs in the app, with checks on your output.

What is a warehouse in this lesson?
  1. The place the shop's tables live, which you slice from
  2. A Spark cluster you must build first
  3. A synonym for neural net

Store, then slice. Not a big-data elective.

2Slice the week you need

If the question is this week's comebacks, you pull customers_week for that week — eight rows after cleaning — not inventory and not last year's invoices. A tiny store export that stacks two weeks has ten rows: the eight week-1 people plus Anu and Bala already written again for week 2. Keep week == 1 and eight rows remain.

Dumping the whole store onto a laptop is how you get a 200,000-row file and then forget the question. Machine Learning's 200-flat rent notebook is already a slice: one table, one job. Be that deliberate on the way in. A ready slice is what you would later hand to a model. This course learns to cut it.

Figure. The export has 10 rows across two weeks. Keeping week 1 leaves the 8 customers this course has been reading. The two week-2 rows stay in the store.

A slice

  1. Name the tablecustomers_week, not every table in the store.
  2. Name the windowthis week, not 'all time'.
  3. StopInventory can wait until a question names it.

Ten rows, one week

The export has 8 rows for week 1 and 2 rows for week 2. How many rows remain after you keep week == 1?

  • 8 + 210 in the export
  • keep week == 18

Pro tip. The two week-2 rows are not junk. They are the wrong window for this question.

Coding lab. Keep week 1 runs in the app, with checks on your output.

The question is 'who came back this week?'. What do you pull?
  1. The customer-week table for this week
  2. Every table in the store since opening day
  3. The 200-flat rent notebook from Machine Learning

A slice matches the question. A dump does not.

3Same name, new week

Anu appears in week 1 and again in week 2. That is not the duplicate you dropped in cleaning. A duplicate was two identical lines in the same week — the export stuttering. Anu in week 2 is a different customer-week: the same person, a new window, maybe a different came_back.

The store can hold both. The slice for 'who came back this week' keeps week-1 Anu and leaves week-2 Anu in the store. If you treated week-2 Anu as a copy and deleted her, you would invent a shop that only ever had one week.

Figure. Anu in week 1 and Anu in week 2 are two customer-weeks. The week-2 row is a new window, not the duplicate you dropped in cleaning.

Anu in two weeks is two cases
weeknamecame_backsame as week-1 Anu?
1Anuyesthis week's Anu — keep for this question
2Anuyesnext week's Anu — a new case, not a copy

Coding lab. Count Anu across weeks runs in the app, with checks on your output.

The export has Anu in week 1 and Anu in week 2. After you filter to week 1, what is week-2 Anu?
  1. A different customer-week still in the store — not a duplicate
  2. The same duplicate Anu you dropped while cleaning
  3. Proof the sheet has nine people this week

Duplicates were two identical lines in one week. A new week is a new case.

4Lab: filter one week

A tiny store export has two weeks of names. week is a column of 1s and 2s. name and came_back are the facts you already know. Keep the rows where week equals 1 and print how many remain. The check looks for 8 — this week's customers, not both weeks stacked.

store[store['week'] == 1] is the slice: every row whose week cell is 1, whole row together. Anu in week 2 is still in store; she is just not in week1. Eight is not a default batch size. It is the window the question named.

No diagram — the slice count is printed by the coding lab.

Lab checklist
StepWhy
Filter week == 1The question named this week
Print len(week1)The check looks for 8
Leave week 2 in the storeAnu next week is another case

Coding lab. Slice week 1 runs in the app, with checks on your output.

The export has 10 rows across two weeks. Why print 8 after the filter?
  1. Week 1 is the slice the question named
  2. Eight is a default batch size
  3. Week 2 rows are duplicates of week 1

Anu in week 2 is a different case, not a duplicate of week 1.

Notes

  • In Data Science because the shop sheet is usually a slice of a larger store — you pull the week you need rather than dumping every table.
  • The eight-row sheet you have been using is a working copy. The durable copy sits with the other shop tables: customers, inventory, invoices. Warehouse here means that store, not a product name.
  • If the question is this week's comebacks, you pull the customer-week table for that week — eight rows after cleaning — not inventory and not last year's invoices.

Exam traps & shortcuts

  • Name the question before you open the sheet — a table without a question is just a dump.
  • A number is a claim only when you can point at the rows that produced it.

Recap

Tables live in a store. Slice the week you need. The same name in another week is another case.

Tables live in a store
customers_week is one customer in one week. inventory is one item on one day. invoices is one supplier bill. Warehouse means that store, not a product name.
Slice the week you need
A ten-row export with two weeks becomes eight rows when you keep week 1. Pull the rows the question can use.
Same name, new week
Anu in week 2 is a different customer-week, not a duplicate of week-1 Anu. Duplicates were two identical lines in one week.
Lab: filter one week
Keep week == 1 and print 8. Week 2 rows stay in the store.

Practise Where tables live

Reading is free and needs no account. Practice, mocks and progress live in the app.

  • A 2-question practice set that ends the chapter
  • 4 quick checks with worked explanations
  • Timed mocks scored with the real marking scheme
  • Readiness tracked per topic, kept on your device
Continue with Google — freeNo card, no trial. Works offline once installed.