Scrapeless Wiki

What Is Data Drift in Scraping? – Definition and How It Works

Informational P3 what is data drift in scraping

Learn what data drift is in collected data, the four kinds that occur, and the checks that catch each before it corrupts a dataset.

Data drift is a change in collected data that comes from the source or the collector rather than from the world. It is the failure that produces wrong answers without producing any error.

1. Four Kinds

Kind What changed Symptom
Schema drift Fields added, renamed, retyped Missing or null fields
Semantic drift A field's meaning changed Values valid but wrong
Distribution drift The population shifted Statistics move
Extraction drift Your selectors degraded Fields silently empty

Only the first is likely to raise an error. The other three produce valid-looking data, which is why they are dangerous.

2. Schema Drift

A source adds a field, renames one, or changes a scalar into a list.

A strict consumer fails loudly, which is inconvenient but safe. A permissive one absorbs it, and the field quietly becomes null for every record from that point.

Detection: compare each batch's field set against the previous one, and alert on any field appearing or disappearing rather than only on parse failures.

3. Semantic Drift Is the Worst

The field is still there, still the same type, still populated β€” and it now means something else.

Real examples: a price that excluded tax and now includes it, a reviews count that became reviews-plus-ratings, a status enum gaining a value your mapping does not cover, a timestamp that changed timezone, or a rating that moved from a 10-point to a 5-point scale.

No structural check catches any of these. What catches them:

  • Range and distribution monitoring. A price series that steps up by a consistent percentage overnight is a tax-inclusion change, not a market movement.
  • Cross-field consistency. A rating above the maximum scale is impossible and therefore diagnostic.
  • Spot comparison against the source page for a sample of records.
  • Watching for unmapped enum values rather than defaulting them silently.

4. Extraction Drift

Your selectors stop matching what they used to. Usually a redesign, sometimes an A/B test serving a variant to some requests.

The insidious version is partial failure: nine fields extract fine and one returns empty. Overall metrics look healthy, and one column quietly fills with nulls.

Detection is per-field fill rate, tracked over time, alerted per field. A fill rate dropping from 98% to 4% is unmistakable β€” and invisible in any aggregate success metric.

5. Distribution Drift Is Not Always a Fault

Sometimes the world changed: a genuine price rise, a seasonal shift, a new market entrant.

That is why distribution monitoring must distinguish a step change from a trend. A step overnight is nearly always a collection or source change; a gradual movement is usually real. Investigating the step first is the correct priority.

6. A Practical Detection Layer

def profile(records):
    fields = {}
    for r in records:
        for k, v in r.items():
            f = fields.setdefault(k, {"n": 0, "filled": 0, "types": set(),
                                      "min": None, "max": None})
            f["n"] += 1
            if v is not None and v != "":
                f["filled"] += 1
                f["types"].add(type(v).__name__)
                if isinstance(v, (int, float)):
                    f["min"] = v if f["min"] is None else min(f["min"], v)
                    f["max"] = v if f["max"] is None else max(f["max"], v)
    return {k: {**v, "fill_rate": v["filled"] / v["n"], "types": sorted(v["types"])}
            for k, v in fields.items()}

Store the profile for every batch. Comparing consecutive profiles catches new fields, vanished fields, changed types, collapsed fill rates, and shifted ranges β€” in one mechanism, without knowing in advance which will break.

7. Why Raw Retention Is the Real Defence

All four kinds of drift are discovered after the fact. What determines whether they are fixable is whether the original payloads still exist.

With the raw responses retained, a discovered drift is a reprocessing job. Without them, the affected period is permanently wrong, because the source cannot be re-read as it was.

That makes raw retention the single most valuable decision in a collection pipeline β€” and it must be made before collection, not after the problem appears.

8. Summary

Data drift is change originating in the source or the collector rather than the world, in four forms: schema, semantic, distribution, and extraction drift.

Only schema drift tends to raise an error, so track per-batch field profiles, per-field fill rates, and value distributions β€” treating an overnight step change as a collection fault rather than a market movement β€” and retain raw payloads, because that is what makes any discovered drift correctable rather than permanent.