Atris

Build a retention table by signup month.
Done by an agent. Checked twice.

A table showing what share of each signup month's customers ordered again in each later month, with every excluded record named.

Have Atris do this for you›

1

Real files in

  • customers.csv
    Sixty seven customer rows with signup dates from January to June, with repeated rows and one missing date. 68 lines, 2 KB.
  • orders.csv
    Two hundred and six order rows for those customers through the end of June, with cancelled orders and orders that match no customer. 194 lines, 8 KB.

Sample data written by Atris. Not a real company.

2

Three steps

  1. 1.Read and clean both files
  2. 2.Count who stayed
  3. 3.Write the table

Claude Sonnet 5.5, 35 seconds. No web. It never saw the check.

3

Checked twice

  • ✓Passed: 6 of 6 signup months appear in both tables with the right number of customers, 64 in all
  • ✓Passed: 21 of 21 active customer counts equal the counts rebuilt from the order file
  • ✓Passed: 21 of 21 percents equal active customers divided by cohort size
  • ✓Passed: 15 of 15 months that have not happened yet are left blank in both tables
  • ✓Passed: summary.md names the best month 1 cohort (2026-02 at 63.6 percent) and the worst (2026-04 at 50.0 percent)
  • ✓Passed: 4 of 4 records left out (no signup date, unknown customer, order before signup month) are named in summary.md
  • ✓Passed: summary.md gives 10 orders left out for their status
  • ✓Passed: 34 of 34 figures, months, dates and ids written in summary.md are found in the tables or the input files

Second review by Claude Opus 5.5: pass.

Then we broke a copy of the output 9 ways on purpose. The check caught 9.

What it wrote. Lines 1 to 7 of retention.csv, copied from the file.
cohort,customers,m0,m1,m2,m3,m4,m5
2026-01,9,100.0,55.6,55.6,44.4,44.4,33.3
2026-02,11,90.9,63.6,54.5,45.5,27.3,
2026-03,14,92.9,57.1,57.1,42.9,,
2026-04,10,100.0,50.0,60.0,,,
2026-05,12,100.0,58.3,,,,
2026-06,8,100.0,,,,,

How this was run

An AI agent on Claude Sonnet 5.5 was given a folder with the files below and a three-step flow, and nothing else. It had no web access and never saw the check. The check was written before the run and made stricter after it. It works the answer out again from the input files. Then Claude Opus 5.5 reviewed the result against the inputs. The input files are sample data written by Atris, with the problems a real week has planted in them.

Run 3 of 3 on 1 December 2026. The agent took 35 seconds. Run 1 passed both checks and the job was run again later. Run 2 passed both checks and the job was run again later. Each run starts clean. Between runs the written flow was made clearer, or a check was corrected or made stricter. Nobody edits the output.

What the second review verified

  • Rebuilt both tables from the input files and every cell matches. For example, cohort 2026-03 has 14 customers with 13/8/8/6 active, which is 92.9/57.1/57.1/42.9, and cohort 2026-01 reaches m5 with 3 of 9 active (33.3).
  • There are 64 customers in cohorts: the duplicate C-3012 is counted once, C-3023 is placed by its earliest signup date (2026-03-03) in 2026-03, and C-3990 has no signup date so it is left out with its orders O-80078 and O-80118.
  • The latest order is dated 2026-06-30, so months that have not happened are left blank, not 0. The best month 1 retention is 2026-02 at 63.6 and the worst is 2026-04 at 50.0, both read correctly from among the 5 cohorts that have reached month 1.
  • The Left out section names the unknown-customer orders O-80047 and O-80155 and the order dated before signup, O-80062, and reports 10 orders left out for status. Those 10 are all cancelled, including O-80156, which belongs to the unknown customer C-4512 but was correctly removed first for its status.

What this run does not show

  • The customers and orders were written for this run from a simple model of who stops buying. The shape of the table is not a real company's.
  • The check shows every figure in the summary exists in the tables or the files. It misses a right number in the wrong sentence, such as the wrong month number.
  • This is the third run and all three passed. The flow was tightened after the second review found a loose range in the second summary.

Would the check catch a wrong answer?

A check that cannot fail proves nothing. After the run we took a copy of the output, broke it one small way at a time and ran the check again. It caught 9 of 9. The check was made stricter after the first try at this, and the same untouched output was graded again.

Open every file

flow.md · the three steps the agent followed
# Build a retention table by signup month

function: data
for: the person who reports on whether customers keep buying
goal: Each signup month shows the share of its customers who ordered in each later month with every record left out named.

## 1. Read and clean both files
Read input/customers.csv and input/orders.csv. Apply these rules:
- A customer_id that appears more than once is one customer. If the rows give different signup dates,
  use the earliest.
- A customer with no signup date cannot be placed in a month. Leave that customer and their orders out.
- Only orders with status `completed` count.
- Leave out any order whose customer_id is not in the customers file.
- Leave out any order dated before the calendar month the customer signed up in.

## 2. Count who stayed
- A customer's cohort is the calendar month of signup, written like 2026-01.
- Month 0 is the signup month, month 1 is the next calendar month and so on.
- A customer is active in a month when they have at least one counted order dated in that month.
- For each cohort and each month number, count the active customers and work out the percent of the
  cohort that count stands for.
- The last month with data is the month of the latest order date in the export. A month number that
  falls after it is not known yet. Leave it blank. Never write 0 for a month that has not happened.

## 3. Write the table
Write output/retention_counts.csv with columns cohort,customers,m0,m1,m2 and so on up to the highest
month number the oldest cohort reaches. One row per cohort, oldest first. customers is the cohort size
and each m column is the number of active customers.
Write output/retention.csv with the same columns and rows, where each m column is the percent of the
cohort with one decimal and no percent sign.
Write output/summary.md for the reader. Start with these three lines: `Customers in cohorts:` with the
number, `Best month 1 retention:` with the cohort and its percent and `Worst month 1 retention:` with
the cohort and its percent. Only cohorts that have reached month 1 can be best or worst. Then one or
two plain sentences on what the table shows. Every number in them is copied from retention.csv as
it is written there. Give no rounded figures and no rough ranges. End with a section "Left out" that names every customer
with no signup date, every order_id with an unknown customer and every order_id dated before the
signup month. It also gives the count of orders left out for their status.

## Done looks like
- Every customer with a signup date is counted in exactly one cohort.
- Every count and percent can be rebuilt from the two files.
- Months that have not happened yet are blank and every record left out is named.
input/customers.csv · 68 lines, 2 KB
customer_id,signup_date,plan
C-3003,2026-01-02,monthly
C-3002,2026-01-19,monthly
C-3007,2026-01-28,monthly
C-3005,2026-01-05,monthly
C-3004,2026-01-27,annual
C-3001,2026-01-11,monthly
C-3009,2026-01-08,monthly
C-3006,2026-01-31,monthly
C-3008,2026-01-18,monthly
C-3017,2026-02-27,monthly
C-3014,2026-02-05,monthly
C-3020,2026-02-09,monthly
C-3012,2026-02-27,monthly
C-3018,2026-02-26,monthly
C-3015,2026-02-17,annual
C-3013,2026-02-17,monthly
C-3016,2026-02-18,monthly
C-3019,2026-02-09,monthly
C-3010,2026-02-16,monthly
C-3011,2026-02-13,annual
C-3012,2026-02-27,monthly
C-3021,2026-03-18,monthly
C-3022,2026-03-18,annual
C-3027,2026-03-24,annual
C-3031,2026-03-28,monthly
C-3028,2026-03-01,annual
C-3029,2026-03-10,monthly
C-3032,2026-03-14,monthly
C-3025,2026-03-24,annual
C-3034,2026-03-10,annual
C-3023,2026-03-03,annual
C-3033,2026-03-31,monthly
C-3030,2026-03-08,annual
C-3024,2026-03-09,monthly
C-3026,2026-03-26,monthly
C-3038,2026-04-15,monthly
C-3043,2026-04-16,monthly
C-3039,2026-04-24,annual
C-3035,2026-04-16,monthly
C-3044,2026-04-29,monthly
C-3041,2026-04-29,annual
C-3040,2026-04-17,monthly
C-3042,2026-04-10,monthly
C-3036,2026-04-13,annual
C-3037,2026-04-16,monthly
C-3023,2026-04-12,annual
C-3052,2026-05-03,monthly
C-3051,2026-05-17,monthly
C-3056,2026-05-08,annual
C-3046,2026-05-02,annual
C-3048,2026-05-20,monthly
C-3047,2026-05-09,monthly
C-3045,2026-05-01,monthly
C-3049,2026-05-20,monthly
C-3054,2026-05-15,monthly
C-3050,2026-05-13,monthly
C-3053,2026-05-15,monthly
C-3055,2026-05-21,monthly
C-3062,2026-06-22,monthly
C-3063,2026-06-14,monthly
C-3064,2026-06-28,monthly
C-3058,2026-06-21,monthly
C-3059,2026-06-07,monthly
C-3061,2026-06-26,annual
C-3060,2026-06-22,monthly
C-3057,2026-06-17,monthly
C-3990,,monthly
input/orders.csv · 194 lines, 8 KB
order_id,customer_id,order_date,amount,status
O-80001,C-3003,2026-01-02,49.50,completed
O-80002,C-3003,2026-01-11,49.50,completed
O-80003,C-3001,2026-01-13,79.00,completed
O-80004,C-3005,2026-01-26,29.00,completed
O-80005,C-3002,2026-01-29,79.99,completed
O-80006,C-3004,2026-01-30,29.99,completed
O-80007,C-3007,2026-01-30,29.50,completed
O-80008,C-3008,2026-01-30,29.99,completed
O-80009,C-3002,2026-01-31,29.99,completed
O-80010,C-3006,2026-01-31,79.99,completed
O-80011,C-3009,2026-01-31,19.00,completed
O-80012,C-3001,2026-02-02,19.99,completed
O-80013,C-3003,2026-02-07,29.00,completed
O-80014,C-3002,2026-02-08,29.00,completed
O-80015,C-3005,2026-02-10,19.00,completed
O-80016,C-3020,2026-02-10,19.00,completed
O-80017,C-3019,2026-02-11,79.00,completed
O-80018,C-3009,2026-02-16,29.00,cancelled
O-80019,C-3011,2026-02-18,29.00,completed
O-80020,C-3006,2026-02-20,29.99,completed
O-80021,C-3014,2026-02-22,19.50,completed
O-80022,C-3010,2026-02-23,29.50,completed
O-80023,C-3013,2026-02-24,29.00,completed
O-80024,C-3016,2026-02-24,19.99,completed
O-80025,C-3015,2026-02-25,19.00,completed
O-80026,C-3017,2026-02-27,29.50,completed
O-80027,C-3012,2026-02-28,79.99,completed
O-80028,C-3017,2026-02-28,29.99,completed
O-80029,C-3019,2026-03-01,29.99,completed
O-80030,C-3001,2026-03-02,79.00,completed
O-80031,C-3003,2026-03-03,29.99,completed
O-80032,C-3006,2026-03-03,29.00,completed
O-80033,C-3010,2026-03-07,29.00,completed
O-80034,C-3030,2026-03-08,49.99,completed
O-80035,C-3002,2026-03-10,79.00,completed
O-80036,C-3024,2026-03-11,29.00,completed
O-80037,C-3003,2026-03-13,79.50,completed
O-80038,C-3029,2026-03-13,79.00,completed
O-80039,C-3016,2026-03-14,19.00,completed
O-80040,C-3034,2026-03-15,49.99,completed
O-80041,C-3006,2026-03-16,49.50,completed
O-80042,C-3010,2026-03-16,79.00,completed
O-80043,C-3013,2026-03-17,29.00,cancelled
O-80044,C-3015,2026-03-17,49.00,completed
O-80045,C-3015,2026-03-17,49.00,cancelled
O-80046,C-3017,2026-03-18,49.99,completed
O-80047,C-4477,2026-03-18,49.00,completed
O-80048,C-3029,2026-03-19,19.99,completed
O-80049,C-3030,2026-03-20,19.00,completed
O-80050,C-3011,2026-03-22,29.00,completed
O-80051,C-3023,2026-03-22,29.50,completed
O-80052,C-3028,2026-03-22,19.00,completed
O-80053,C-3025,2026-03-24,79.99,completed
O-80054,C-3021,2026-03-25,19.99,completed
O-80055,C-3011,2026-03-26,29.99,completed
O-80056,C-3032,2026-03-27,19.99,completed
O-80057,C-3027,2026-03-28,29.00,completed
O-80058,C-3002,2026-03-29,29.99,completed
O-80059,C-3018,2026-03-29,29.50,completed
O-80060,C-3019,2026-03-30,29.00,completed
O-80061,C-3031,2026-03-30,29.00,completed
O-80062,C-3039,2026-03-30,29.00,completed
O-80063,C-3001,2026-03-31,29.00,completed
O-80064,C-3005,2026-03-31,29.00,completed
O-80065,C-3009,2026-03-31,29.00,cancelled
O-80066,C-3026,2026-03-31,79.00,completed
O-80067,C-3033,2026-03-31,49.00,completed
O-80068,C-3024,2026-04-01,29.50,completed
O-80069,C-3001,2026-04-02,79.00,completed
O-80070,C-3005,2026-04-04,49.99,completed
O-80071,C-3026,2026-04-04,49.99,completed
O-80072,C-3030,2026-04-04,29.00,completed
O-80073,C-3002,2026-04-05,49.99,completed
O-80074,C-3019,2026-04-06,29.00,completed
O-80075,C-3006,2026-04-07,79.50,completed
O-80076,C-3008,2026-04-07,29.00,cancelled
O-80077,C-3029,2026-04-09,49.00,completed
O-80078,C-3990,2026-04-09,29.00,completed
O-80079,C-3022,2026-04-11,29.00,completed
O-80080,C-3030,2026-04-12,49.50,completed
O-80081,C-3005,2026-04-13,49.99,completed
O-80082,C-3018,2026-04-13,29.99,completed
O-80083,C-3034,2026-04-13,29.50,completed
O-80084,C-3023,2026-04-15,19.50,completed
O-80085,C-3027,2026-04-16,49.00,completed
O-80086,C-3027,2026-04-16,29.00,completed
O-80087,C-3017,2026-04-17,19.00,completed
O-80088,C-3037,2026-04-18,79.00,completed
O-80089,C-3042,2026-04-18,29.00,completed
O-80090,C-3012,2026-04-19,29.00,cancelled
O-80091,C-3038,2026-04-19,29.00,completed
O-80092,C-3024,2026-04-21,29.00,completed
O-80093,C-3043,2026-04-22,19.00,completed
O-80094,C-3016,2026-04-23,29.00,completed
O-80095,C-3039,2026-04-24,29.00,completed
O-80096,C-3036,2026-04-25,29.50,completed
O-80097,C-3011,2026-04-26,19.00,completed
O-80098,C-3006,2026-04-27,29.00,completed
O-80099,C-3010,2026-04-27,19.99,completed
O-80100,C-3035,2026-04-28,49.99,completed
O-80101,C-3040,2026-04-29,79.00,completed
O-80102,C-3044,2026-04-29,29.00,completed
O-80103,C-3029,2026-04-30,29.00,completed
O-80104,C-3041,2026-04-30,29.00,completed
O-80105,C-3043,2026-04-30,49.00,completed
O-80106,C-3011,2026-05-01,29.00,completed
O-80107,C-3041,2026-05-01,29.00,completed
O-80108,C-3030,2026-05-04,29.00,completed
O-80109,C-3030,2026-05-04,29.00,cancelled
O-80110,C-3034,2026-05-06,29.00,completed
O-80111,C-3035,2026-05-06,29.00,completed
O-80112,C-3052,2026-05-06,49.99,completed
O-80113,C-3016,2026-05-08,19.99,completed
O-80114,C-3023,2026-05-08,19.50,completed
O-80115,C-3046,2026-05-08,29.50,completed
O-80116,C-3040,2026-05-09,29.00,completed
O-80117,C-3002,2026-05-11,29.99,completed
O-80118,C-3990,2026-05-11,29.00,completed
O-80119,C-3041,2026-05-12,49.00,completed
O-80120,C-3037,2026-05-13,49.99,completed
O-80121,C-3050,2026-05-13,29.00,completed
O-80122,C-3045,2026-05-14,19.00,completed
O-80123,C-3005,2026-05-15,29.00,completed
O-80124,C-3026,2026-05-16,29.00,completed
O-80125,C-3040,2026-05-16,79.00,completed
O-80126,C-3050,2026-05-17,49.00,completed
O-80127,C-3056,2026-05-17,29.00,completed
O-80128,C-3053,2026-05-18,29.50,completed
O-80129,C-3001,2026-05-19,29.00,completed
O-80130,C-3054,2026-05-19,29.00,completed
O-80131,C-3027,2026-05-20,29.50,completed
O-80132,C-3047,2026-05-20,29.50,completed
O-80133,C-3047,2026-05-20,29.50,cancelled
O-80134,C-3051,2026-05-20,49.00,completed
O-80135,C-3049,2026-05-21,49.99,completed
O-80136,C-3024,2026-05-22,79.99,completed
O-80137,C-3055,2026-05-22,19.99,completed
O-80138,C-3015,2026-05-23,29.99,completed
O-80139,C-3048,2026-05-24,29.00,completed
O-80140,C-3006,2026-05-25,79.50,completed
O-80141,C-3046,2026-05-25,49.00,completed
O-80142,C-3010,2026-05-26,29.00,completed
O-80143,C-3018,2026-05-26,29.99,completed
O-80144,C-3022,2026-05-27,29.00,completed
O-80145,C-3010,2026-05-29,29.99,completed
O-80146,C-3016,2026-05-29,49.00,completed
O-80147,C-3030,2026-05-29,29.50,completed
O-80148,C-3053,2026-05-29,79.00,completed
O-80149,C-3013,2026-05-30,29.00,cancelled
O-80150,C-3029,2026-05-31,29.00,completed
O-80151,C-3037,2026-05-31,29.00,completed
O-80152,C-3039,2026-05-31,29.50,completed
O-80153,C-3040,2026-06-01,29.99,completed
O-80154,C-3046,2026-06-02,49.00,completed
O-80155,C-4512,2026-06-02,19.00,completed
O-80156,C-4512,2026-06-02,19.00,cancelled
O-80157,C-3037,2026-06-03,49.99,completed
O-80158,C-3039,2026-06-04,19.50,completed
O-80159,C-3043,2026-06-06,49.99,completed
O-80160,C-3051,2026-06-06,49.00,completed
O-80161,C-3059,2026-06-07,29.99,completed
O-80162,C-3002,2026-06-09,49.00,completed
O-80163,C-3011,2026-06-09,79.99,completed
O-80164,C-3019,2026-06-10,49.00,completed
O-80165,C-3001,2026-06-12,19.00,completed
O-80166,C-3030,2026-06-12,49.50,completed
O-80167,C-3023,2026-06-13,19.99,completed
O-80168,C-3022,2026-06-14,29.00,completed
O-80169,C-3044,2026-06-15,29.00,completed
O-80170,C-3046,2026-06-15,19.00,completed
O-80171,C-3050,2026-06-15,29.00,completed
O-80172,C-3063,2026-06-15,29.50,completed
O-80173,C-3054,2026-06-17,79.00,completed
O-80174,C-3005,2026-06-19,29.00,completed
O-80175,C-3037,2026-06-19,49.00,completed
O-80176,C-3027,2026-06-20,79.00,completed
O-80177,C-3026,2026-06-22,79.00,completed
O-80178,C-3015,2026-06-23,79.50,completed
O-80179,C-3040,2026-06-23,29.00,completed
O-80180,C-3060,2026-06-23,29.00,completed
O-80181,C-3053,2026-06-24,29.00,completed
O-80182,C-3062,2026-06-24,49.50,completed
O-80183,C-3058,2026-06-26,29.00,completed
O-80184,C-3044,2026-06-27,29.50,completed
O-80185,C-3045,2026-06-27,49.00,completed
O-80186,C-3063,2026-06-27,49.00,completed
O-80187,C-3064,2026-06-28,49.00,completed
O-80188,C-3029,2026-06-29,19.50,completed
O-80189,C-3035,2026-06-29,19.99,completed
O-80190,C-3057,2026-06-29,19.00,completed
O-80191,C-3061,2026-06-29,19.99,completed
O-80192,C-3056,2026-06-30,19.50,completed
O-80193,C-3064,2026-06-30,49.00,completed
output/retention.csv · written by the agent, 7 lines
cohort,customers,m0,m1,m2,m3,m4,m5
2026-01,9,100.0,55.6,55.6,44.4,44.4,33.3
2026-02,11,90.9,63.6,54.5,45.5,27.3,
2026-03,14,92.9,57.1,57.1,42.9,,
2026-04,10,100.0,50.0,60.0,,,
2026-05,12,100.0,58.3,,,,
2026-06,8,100.0,,,,,
output/retention_counts.csv · written by the agent, 7 lines
cohort,customers,m0,m1,m2,m3,m4,m5
2026-01,9,9,5,5,4,4,3
2026-02,11,10,7,6,5,3,
2026-03,14,13,8,8,6,,
2026-04,10,10,5,6,,,
2026-05,12,12,7,,,,
2026-06,8,8,,,,,
output/summary.md · written by the agent, 16 lines
Customers in cohorts: 64
Best month 1 retention: 2026-02 at 63.6
Worst month 1 retention: 2026-04 at 50.0

Every cohort from 2026-01 to 2026-05 has reached month 1; 2026-02 kept 63.6 and 2026-04 kept 50.0 of its customers in month 1. The latest order in the export is dated 2026-06-30, so months after June 2026 are blank, and 2026-06 only has month 0 (100.0).

Percents are of cohort size, no percent sign. Counts are in retention_counts.csv.

## Left out

- Customers with no signup date (left out with their orders): C-3990. Its orders O-80078 and O-80118 are left out with it.
- Orders with an unknown customer_id (not in customers.csv): O-80047, O-80155.
- Orders dated before the customer's signup month: O-80062.
- Orders left out for status (not `completed`): 10. All 10 are `cancelled`.

Notes on duplicates: C-3012 appears twice with the same signup date, so it counts once. C-3023 appears twice (2026-03-03 and 2026-04-12), so it uses the earliest, 2026-03-03, and sits in the 2026-03 cohort only.
check.py · the check, written before the run
"""Rebuilds the retention table from the customer and order files and compares it with what the agent wrote."""
import csv, re, sys
from pathlib import Path
root = Path(sys.argv[1]); ok = True
def say(passed, text):
    global ok; ok = ok and passed; print(("PASS " if passed else "FAIL ") + text)
def idx(ym): return int(ym[:4]) * 12 + int(ym[5:7])
def num(s):
    try: return float(str(s).replace("%", "").strip())
    except ValueError: return None
signup, nodate, dates, seen_c, repeat_c = {}, set(), set(), set(), set()
for r in csv.DictReader((root/"input/customers.csv").open()):
    c, d = r["customer_id"].strip(), r["signup_date"].strip()
    dates.add(d); repeat_c |= {c} & seen_c; seen_c.add(c)
    if not d: nodate.add(c)
    elif c not in signup or d < signup[c]: signup[c] = d
nodate -= set(signup)
active, unknown, early, last, by_status, aside = set(), [], [], "", {}, set()
for r in csv.DictReader((root/"input/orders.csv").open()):
    c, d = r["customer_id"].strip(), r["order_date"].strip()
    last = max(last, d[:7]); dates.add(d)
    if r["status"].strip().lower() != "completed":
        by_status[r["status"].strip().lower()] = by_status.get(r["status"].strip().lower(), 0) + 1; aside.add(r["order_id"].strip()); continue
    if c in nodate: aside.add(r["order_id"].strip()); continue
    if c not in signup: unknown.append(r["order_id"].strip()); continue
    n = idx(d[:7]) - idx(signup[c][:7])
    if n < 0: early.append(r["order_id"].strip()); continue
    active.add((c, n))
cohorts = sorted({d[:7] for d in signup.values()})
size = {co: sum(1 for d in signup.values() if d[:7] == co) for co in cohorts}
reach = {co: idx(last) - idx(co) for co in cohorts}
top = max(reach.values())
count = {(co, n): sum(1 for c, d in signup.items() if d[:7] == co and (c, n) in active) for co in cohorts for n in range(reach[co] + 1)}
p1, p2 = root/"output/retention_counts.csv", root/"output/retention.csv"
if not p1.exists() or not p2.exists():
    say(False, "output/retention_counts.csv and output/retention.csv were not both written"); sys.exit(1)
gc = {r.get("cohort", "").strip(): r for r in csv.DictReader(p1.open())}
gp = {r.get("cohort", "").strip(): r for r in csv.DictReader(p2.open())}
sizes_ok = sum(1 for co in cohorts if co in gc and num(gc[co].get("customers")) == size[co] and co in gp and num(gp[co].get("customers")) == size[co])
say(list(gc) == cohorts and list(gp) == cohorts and sizes_ok == len(cohorts), f"{sizes_ok} of {len(cohorts)} signup months appear in both tables with the right number of customers, {sum(size.values())} in all")
cr = sum(1 for k, v in count.items() if k[0] in gc and num(gc[k[0]].get(f"m{k[1]}")) == v)
say(cr == len(count), f"{cr} of {len(count)} active customer counts equal the counts rebuilt from the order file")
pr = sum(1 for k, v in count.items() if k[0] in gp and num(gp[k[0]].get(f"m{k[1]}")) is not None and abs(num(gp[k[0]][f"m{k[1]}"]) - v / size[k[0]] * 100) <= 0.051)
say(pr == len(count), f"{pr} of {len(count)} percents equal active customers divided by cohort size")
future = [(co, n) for co in cohorts for n in range(reach[co] + 1, top + 1)]
blank = sum(1 for co, n in future if co in gc and co in gp and not (gc[co].get(f"m{n}") or "").strip() and not (gp[co].get(f"m{n}") or "").strip())
say(blank == len(future), f"{blank} of {len(future)} months that have not happened yet are left blank in both tables")
summary = (root/"output/summary.md").read_text() if (root/"output/summary.md").exists() else ""
def line(label):
    m = re.search(re.escape(label) + r"[^\n]*", summary, re.I); return m.group(0) if m else ""
m1 = {co: count[(co, 1)] / size[co] * 100 for co in cohorts if reach[co] >= 1}
best, worst = max(m1, key=m1.get), min(m1, key=m1.get)
def has(label, co): return co in line(label) and any(abs(float(x) - m1[co]) <= 0.051 for x in re.findall(r"\d+\.\d+|\d+", line(label).replace(co, "")))
total_ok = re.search(r"\b%d\b" % sum(size.values()), line("Customers in cohorts:")) is not None
say(total_ok and has("Best month 1 retention:", best) and has("Worst month 1 retention:", worst), f"summary.md names the best month 1 cohort ({best} at {m1[best]:.1f} percent) and the worst ({worst} at {m1[worst]:.1f} percent)")
out = sorted(nodate) + unknown + early
named = sum(1 for x in out if x in summary)
say(named == len(out), f"{named} of {len(out)} records left out (no signup date, unknown customer, order before signup month) are named in summary.md")
# the count of orders left out for their status, read from the lines that speak of status
plain = re.sub(r"\b[A-Za-z]+-\d+\b", " ", summary)   # a customer or order id is a name, not a figure
off = sum(by_status.values())
on_status = [int(x) for ln in plain.splitlines() if re.search(r"\bstatus\b", ln, re.I) for x in re.findall(r"(?<![\w.-])\d+(?![\w.-]*\d)", ln)]
say(on_status[:1] == [off] and all(x == off or x in by_status.values() for x in on_status), f"summary.md gives {off} orders left out for their status")
# everything else written in the summary has to be found in the tables or the input files
ids = re.findall(r"\b[A-Za-z]+-\d+\b", summary)
idr = sum(1 for x in ids if x in out or x in aside or x in repeat_c)
days = re.findall(r"\d{4}-\d{2}-\d{2}", plain); plain = re.sub(r"\d{4}-\d{2}-\d{2}", " ", plain)
months = re.findall(r"\d{4}-\d{2}", plain); plain = re.sub(r"\d{4}-\d{2}", " ", plain)
real_months = {d[:7] for d in dates if d}
dr = sum(1 for d in days if d in dates) + sum(1 for m in months if m in real_months)
pcts = [v / size[k[0]] * 100 for k, v in count.items()]
wholes = set(count.values()) | set(size.values()) | set(range(top + 1)) | {sum(size.values()), off, len(cohorts)} | {int(m[:4]) for m in real_months} | set(by_status.values())
figs = re.findall(r"(?<![\w.])\d[\d,]*(?:\.\d+)?", plain)
fr = sum(1 for t in figs if (any(abs(float(t) - x) <= 0.051 for x in pcts) if "." in t else int(t.replace(",", "")) in wholes))
total, good = len(figs) + len(days) + len(months) + len(ids), fr + dr + idr
say(len(figs) > 0 and good == total, f"{good} of {total} figures, months, dates and ids written in summary.md are found in the tables or the input files")
sys.exit(0 if ok else 1)

customers.csv: sample data written by Atris. Fingerprint c2152232ef9f.

orders.csv: sample data written by Atris. Fingerprint 98b8ab847d56.

retention.csv: written by the agent. Fingerprint 9af97140d1d9.

retention_counts.csv: written by the agent. Fingerprint 43619df4940e.

summary.md: written by the agent. Fingerprint 64be60c74c19.


More data and analysis work, and every other desk job

For agentsGitHub
What is AtrisBlogApp StorePricingPrivacyTerms