|
| 1 | +Data Profiling & Schema Inference |
| 2 | +================================= |
| 3 | + |
| 4 | +``data_quality.validate_rows`` *consumes* a hand-written schema and |
| 5 | +``stats.describe`` summarises one numeric list — nothing surveyed a whole |
| 6 | +row-set to report per-column null fraction, cardinality, inferred type, value |
| 7 | +ranges, and top values, nor proposed a starting schema. This adds the profiler |
| 8 | +step that feeds the existing validator. |
| 9 | + |
| 10 | +Pure standard library (``collections`` + reuse of ``stats``); imports no |
| 11 | +``PySide6``. Every function is pure (rows in, dict out), so it is fully |
| 12 | +deterministic in CI. |
| 13 | + |
| 14 | +Headless API |
| 15 | +------------ |
| 16 | + |
| 17 | +.. code-block:: python |
| 18 | +
|
| 19 | + from je_auto_control import profile_rows, infer_schema, validate_rows, load_rows |
| 20 | +
|
| 21 | + rows = load_rows("export.csv") |
| 22 | + profile = profile_rows(rows) |
| 23 | + # profile["columns"]["age"] -> {count, null_count, null_fraction, distinct, |
| 24 | + # unique, inferred_type, top_values, min, max, mean} |
| 25 | +
|
| 26 | + schema = infer_schema(rows) # validate_rows-compatible |
| 27 | + report = validate_rows(rows, schema) |
| 28 | +
|
| 29 | +``profile_rows`` returns ``{row_count, columns}`` where each column carries its |
| 30 | +count, null count and fraction, distinct count, a uniqueness flag, the inferred |
| 31 | +type (``int`` / ``number`` / ``bool`` / ``str``), the top values with counts, |
| 32 | +and ``min`` / ``max`` / ``mean`` for numeric columns. ``infer_schema`` turns |
| 33 | +that profile into a schema the existing ``validate_rows`` understands: a column |
| 34 | +is ``required`` when it has no nulls, ``unique`` when every non-null value is |
| 35 | +distinct, and carries numeric bounds. Pass an explicit ``columns`` list to |
| 36 | +restrict either function to a subset. |
| 37 | + |
| 38 | +Executor commands |
| 39 | +----------------- |
| 40 | + |
| 41 | +``AC_profile_rows`` profiles a ``rows`` list (optional ``columns`` subset) and |
| 42 | +returns ``{profile}``. ``AC_infer_schema`` returns ``{schema}``. Both are |
| 43 | +exposed as MCP tools (``ac_profile_rows`` / ``ac_infer_schema``) and as Script |
| 44 | +Builder commands under **Data**. |
0 commit comments