{
 "id": "late_deliveries",
 "kind": "analysis R4",
 "title": "How much lower do late deliveries score?",
 "question": "When a marketplace order arrives after the date the customer was promised, how much lower is its review score, how does that change with the days late, and does it hold once delivery status and order value are taken into account?",
 "source": {
  "name": "Brazilian E-Commerce Public Dataset by Olist",
  "publisher": "Olist",
  "url": "https://www.kaggle.com/datasets/olistbr/brazilian-ecommerce",
  "license": "CC BY-NC-SA 4.0",
  "as_of": "2018",
  "caveat": "Real but anonymized orders from Olist, a Brazilian marketplace, 2016 to 2018. Almost every order has a review. The data shows that late orders score lower; it does not show why."
 },
 "kpis": [
  {
   "label": "Delivered orders that arrived late",
   "value": "6.7%",
   "note": "6,381 of 95,824 delivered orders with a review"
  },
  {
   "label": "Average score, late against on time",
   "value": "2.27",
   "note": "against 4.29 on time or early, out of 5"
  },
  {
   "label": "One-star reviews, late orders",
   "value": "53.8%",
   "note": "against 6.6% on time or early"
  },
  {
   "label": "Late orders answered before arrival",
   "value": "64.0%",
   "note": "Olist sends its survey on delivery or when the estimated date is due"
  },
  {
   "label": "Late orders answered on or after arrival",
   "value": "3.41",
   "note": "against 4.29 on time or early"
  }
 ],
 "finding": "Late orders average 2.27 stars against 4.29 for orders on time or early, 2.02 lower, and 53.8% of them get one star (against 6.6%). The score falls over the first week late: 3.29 at 1 to 3 days, 2.10 at 4 to 7. Part of that is timing: Olist sends its review survey on delivery or when the estimated date is due, and 64.0% of late orders were answered before they arrived. Late orders answered on or after arrival still average 3.41, 0.88 below on-time orders. The overall gap is about two stars in every order value band.",
 "recommendation": "For a late order, the review is often written before the order arrives. Worth testing: delivery promises the network can keep, and a message to the customer before the promised date passes, so the survey does not land on an order that has not come.",
 "buckets": [
  [
   "15 or more days early",
   4.32,
   34771,
   6.5,
   64.3
  ],
  [
   "8 to 14 days early",
   4.31,
   36158,
   6.4,
   63.0
  ],
  [
   "1 to 7 days early",
   4.2,
   17234,
   7.1,
   57.5
  ],
  [
   "On the estimated day",
   4.03,
   1280,
   8.5,
   50.6
  ],
  [
   "1 to 3 days late",
   3.29,
   1852,
   25.1,
   33.2
  ],
  [
   "4 to 7 days late",
   2.1,
   1748,
   58.6,
   14.1
  ],
  [
   "8 to 14 days late",
   1.67,
   1446,
   70.6,
   6.8
  ],
  [
   "15 or more days late",
   1.72,
   1335,
   69.0,
   7.2
  ]
 ],
 "score_mix": [
  [
   "On time or early",
   6.6,
   2.6,
   8.1,
   20.4,
   62.3,
   89443
  ],
  [
   "1 to 3 days late",
   25.1,
   7.0,
   14.7,
   20.0,
   33.2,
   1852
  ],
  [
   "4 to 7 days late",
   58.6,
   9.1,
   9.8,
   8.4,
   14.1,
   1748
  ],
  [
   "8 or more days late",
   69.8,
   9.5,
   9.0,
   4.7,
   7.0,
   2781
  ]
 ],
 "timing": [
  [
   "On time or early",
   3.86,
   4.29,
   153,
   89290,
   0.2
  ],
  [
   "1 to 3 days late",
   1.54,
   3.51,
   205,
   1647,
   11.1
  ],
  [
   "4 to 7 days late",
   1.6,
   3.18,
   1196,
   552,
   68.4
  ],
  [
   "8 or more days late",
   1.65,
   3.11,
   2685,
   96,
   96.5
  ]
 ],
 "status": [
  [
   "Delivered on time or early",
   4.29,
   89443,
   9.3
  ],
  [
   "Delivered late",
   2.27,
   6381,
   62.4
  ],
  [
   "Shipped, never marked delivered",
   2.0,
   1032,
   69.6
  ],
  [
   "Canceled",
   1.8,
   605,
   76.9
  ],
  [
   "Unavailable",
   1.53,
   595,
   84.9
  ],
  [
   "Not yet shipped (invoiced, processing, created, approved)",
   1.46,
   609,
   87.5
  ]
 ],
 "value_bands": [
  [
   "Up to R$61.80",
   4.35,
   2.39,
   1.97,
   22577,
   1358,
   5.7
  ],
  [
   "R$61.80 to R$105.28",
   4.31,
   2.28,
   2.04,
   22494,
   1579,
   6.6
  ],
  [
   "R$105.28 to R$176.16",
   4.29,
   2.29,
   2.0,
   22219,
   1649,
   6.9
  ],
  [
   "Over R$176.16",
   4.2,
   2.16,
   2.04,
   22153,
   1795,
   7.5
  ]
 ],
 "months": [
  [
   "2017-01",
   4.26,
   null,
   2.8,
   21,
   720
  ],
  [
   "2017-02",
   4.26,
   2.14,
   2.6,
   42,
   1601
  ],
  [
   "2017-03",
   4.27,
   2.39,
   4.5,
   113,
   2414
  ],
  [
   "2017-04",
   4.25,
   2.46,
   6.4,
   147,
   2143
  ],
  [
   "2017-05",
   4.28,
   2.74,
   2.8,
   99,
   3418
  ],
  [
   "2017-06",
   4.28,
   2.43,
   3.0,
   92,
   3019
  ],
  [
   "2017-07",
   4.32,
   2.25,
   2.7,
   105,
   3737
  ],
  [
   "2017-08",
   4.36,
   2.65,
   2.9,
   121,
   4044
  ],
  [
   "2017-09",
   4.34,
   2.59,
   4.3,
   177,
   3941
  ],
  [
   "2017-10",
   4.27,
   2.55,
   4.0,
   179,
   4267
  ],
  [
   "2017-11",
   4.24,
   2.2,
   12.3,
   887,
   6350
  ],
  [
   "2017-12",
   4.24,
   2.11,
   7.3,
   401,
   5060
  ],
  [
   "2018-01",
   4.23,
   2.01,
   5.6,
   396,
   6617
  ],
  [
   "2018-02",
   4.2,
   1.91,
   14.0,
   912,
   5595
  ],
  [
   "2018-03",
   4.21,
   2.07,
   18.7,
   1296,
   5652
  ],
  [
   "2018-04",
   4.3,
   2.23,
   4.4,
   297,
   6455
  ],
  [
   "2018-05",
   4.34,
   2.76,
   6.5,
   437,
   6285
  ],
  [
   "2018-06",
   4.33,
   2.31,
   1.2,
   71,
   6001
  ],
  [
   "2018-07",
   4.37,
   2.76,
   3.3,
   200,
   5918
  ],
  [
   "2018-08",
   4.4,
   2.99,
   6.1,
   385,
   5945
  ]
 ],
 "numbers": {
  "orders": 99441,
  "reviews": 99224,
  "orders_with_review": 98673,
  "orders_with_more_than_one_review": 547,
  "orders_without_review": 768,
  "orders_used": 98673,
  "delivered": 95824,
  "delivered_no_date": 8,
  "delivered_no_items": 0,
  "late": 6381,
  "ontime": {
   "orders": 89443,
   "avg": 4.290386055923885,
   "one_star": 0.06618740426864037,
   "five_star": 0.6226647138400992,
   "one_or_two": 0.09267354628087161
  },
  "late_stats": {
   "orders": 6381,
   "avg": 2.270490518727472,
   "one_star": 0.5376900172386774,
   "five_star": 0.16533458705532048,
   "one_or_two": 0.6241968343519825
  },
  "undelivered": {
   "orders": 2841,
   "avg": 1.7412882787750792,
   "one_or_two": 0.7817669834565294
  },
  "value_cuts_brl": [
   61.8,
   105.28,
   176.16
  ],
  "months_with_30_late": 19,
  "months_late_lower": 19,
  "months_before_2017_not_charted": {
   "2016-09": 1,
   "2016-10": 262,
   "2016-12": 1
  },
  "answered_on_or_after_delivery_avg": [
   4.291130025758764,
   3.41437908496732
  ],
  "answered_on_or_after_delivery_n": [
   89290,
   2295
  ],
  "late_answered_before_arrival_avg": 1.6279980420949585,
  "answered_before_delivery": 4239,
  "survey_sent_dates_at_midnight": 99139,
  "answered_before_delivery_late": 4086,
  "robust_first_review": [
   4.290810907505339,
   2.2731546779501643
  ],
  "purchase_period": [
   "2016-09-15 12:16:38",
   "2018-08-29 15:00:37"
  ],
  "reviews_sha256": "012b61c7593e34f51fa614efdf802b9c7056ce6aae5307ddb93236e7cfc797d7",
  "reviews_git_blob": "2c32975b59dfa8335963fd4e94e3bebd60bd16f6",
  "older_mirror": {
   "rows": 100000,
   "rows_not_in_kaggle_size_file": 776,
   "exact_duplicate_rows": 0
  }
 },
 "sample_queries": [
  {
   "label": "Score by days late (DuckDB, the published CSV files)",
   "sql": "-- Late deliveries against the review score (delivered orders with a review)\nWITH review AS (            -- one review per order: the most recently answered\n    SELECT order_id, review_score\n    FROM (SELECT *, row_number() OVER (PARTITION BY order_id\n                                       ORDER BY review_answer_timestamp DESC, review_id) AS rn\n          FROM olist_order_reviews)\n    WHERE rn = 1\n),\ndelivered AS (\n    SELECT o.order_id, r.review_score,\n           date_diff('day', o.order_estimated_delivery_date::DATE,\n                            o.order_delivered_customer_date::DATE) AS days_late\n    FROM olist_orders o JOIN review r USING (order_id)\n    WHERE o.order_status = 'delivered' AND o.order_delivered_customer_date IS NOT NULL\n)\nSELECT CASE WHEN days_late <= 0 THEN 'On time or early'\n            WHEN days_late <= 3 THEN '1 to 3 days late'\n            WHEN days_late <= 7 THEN '4 to 7 days late'\n            ELSE '8 or more days late' END AS delivery,\n       count(*) AS orders,\n       round(avg(review_score), 2) AS avg_score,\n       round(100.0 * count(*) FILTER (WHERE review_score = 1) / count(*), 1) AS one_star_pct\nFROM delivered\nGROUP BY 1\nORDER BY min(days_late)"
  }
 ],
 "cleaning": [
  "Joined 99,441 orders to their reviews on order_id. 99,224 reviews cover 98,673 orders; for the 547 orders with more than one review the most recently answered is used, and the 768 orders without a review are left out (98,673 orders used).",
  "Days late: the delivery date minus the estimated delivery date shown to the customer at purchase, in calendar days. Late means 1 day or more. 95,824 delivered orders have both dates; 8 marked delivered have no delivery date and are left out.",
  "Order value: item prices plus freight, in Brazilian reais, summed over the order's items."
 ],
 "checks": [
  "The orders and order items files match Kaggle's listed file sizes; the reviews file (downloaded Oct 12, 2026 from a GitHub copy) matches Kaggle's listed size and GitHub's own checksum for it.",
  "The SQL below, run in DuckDB 1.5.5, returns the counts, averages and one-star shares on this page. Every number was recomputed by separate code (verify_r4.py: plain Python and the csv module) and matches.",
  "Using each order's first review instead of its last gives on time or early 4.29 and late 2.27, the same as the page to two decimals.",
  "In all 19 purchase months from January 2017 with at least 30 late orders, late orders average lower than orders on time or early."
 ]
}