Skip to content
Start free

Recompute the number, then count it by hand

Rerun the AI's count yourself, then list the paid orders by hand and see what the six rows really name.

2 parts · 6 and 5 min

Free course. Your Maestro, an AI, .

On the previous page you traced the AI's three lines of and predicted that len(paid) would print 6. Reading the code showed you what each line computes in principle. Now you will run two checks on that 6: first by executing the AI's calculation yourself on the orders table, and second by printing the filtered rows and listing by hand what they actually name.

Running the code yourself checks whether the AI's lines run cleanly and reproduce 6 on your data. In the exercise below, the eight rows of the orders table are already loaded into a variable named data. The first line, paid = data[data["status"] == "paid"], checks every row of data for status == "paid" and stores the matching rows in a filtered table named paid. The second line, print("Paid rows:", len(paid)), counts how many rows are in paid.

At the bottom of the editor sits a commented-out line: # print(paid[["order_id", "customer_id"]]). Because it starts with #, Python ignores it on your first run. When you delete the # at the start of that line and run the code again, pandas prints only the order_id and customer_id columns of paid. Notice the double square brackets in paid[["order_id", "customer_id"]]: the outer brackets select from paid, and the inner brackets ["order_id", "customer_id"] list the two column names you want to display together. If the second print line fails when you uncomment it, ask your Maestro to look at your code.

Try it

Run the starter code once to see Paid rows: 6. Then remove the # before the final print line and run it again so the output lists the six paid orders with their customer IDs.

Your turn

Run the AI's code on the orders table. Then add a line that prints the paid rows with only their order_id and customer_id columns. You're done when you can see the six paid orders and write down, by hand, which customer placed each one.

Data: shop-orders, 8 rows
The exercise's data, "shop-orders". Your edits run with your code.
RowRemove
1
2
3
4
5
6
7
8

A good place to stop. Up next: Count the paid rows by hand · 5 min

Count the paid rows by hand

Your second run printed six rows: P01, P02, P04, P05, P06, and P08. Before you trust the AI's 6 as the answer to "How many customers have at least one paid order?", copy this table onto paper or into a message to your Maestro and fill in the customer_id column from your printed output:

order_idcustomer_id
P01
P02
P04
P05
P06
P08

Once you have written all six customer IDs, check two things by hand:

  1. How many rows are in your list?
  2. Look down the customer_id column you filled in. Does every row name a different customer, or do some customer IDs appear more than once? Count how many distinct customers appear across the six paid orders.

Share your filled-in list of six orders and your customer count with your Maestro to verify what you found.

It can feel redundant to write six values by hand right after Python printed Paid rows: 6. Code does arithmetic fast and does not lose count halfway down a column, which makes it tempting to skip the manual count altogether. Yet rerunning the AI's code only repeats the AI's exact instructions. If those instructions counted the wrong , your rerun will count the wrong grain too and hand you back the exact same number. Scanning the filtered rows by hand, whether on all six rows of a small table or as a on a handful of rows from a large table, forces you to look at the IDs themselves and see when two rows belong to the same person.

What a matching rerun proves, and what it leaves open

When your run printed Paid rows: 6, you got the exact number the AI reported. That match gives you one genuine piece of evidence, and it leaves two traps wide open.

What the match proves is reproducibility. Running paid = data[data["status"] == "paid"] followed by len(paid) on this eight-row table produces 6 every time. You now know the number 6 was not invented at random, and you know that counting paid rows is compatible with the AI's result.

What a matching rerun does not prove is which procedure the AI actually used when it gave you that number, unless you are running the exact code the AI executed to produce it. When an assistant states a number in prose, or writes a snippet of code afterward to explain a number it already gave you, several different calculations on a small table can happen to land on 6. Seeing 6 come out of your script shows only that this calculation is compatible with the AI's number.

More importantly, a matching rerun never proves that 6 answers your question. Recomputing a number tests whether the code produces the output on your table, while leaving open whether the code's definition matches your question. You asked how many customers have at least one paid order. The AI's code filtered to paid rows and called len(paid), which counts orders. Rerunning that code confirms that there are 6 paid orders while leaving the mismatch between orders and customers untouched. Ask your Maestro if you want to talk through why a reproducible number can still answer the wrong question.

Note: A matching rerun is half a check

Getting the same number when you rerun the AI's code proves that the calculation reproduces 6 on this table. It does not prove which procedure produced an unlogged AI answer, and it does not prove that 6 counts what your question asked for.

Check yourself: You rerun the AI's code on shop-orders and your output prints Paid rows: 6, matching the 6 the AI gave you. What does that match establish?