API Reference¶
recx.Rec(columns, check_all=True, check_missing_indices=True, check_extra_indices=True, align_date_col=None)
¶
Configure and run reconciliation between two DataFrames.
Steps performed when :meth:run is invoked:
- Optionally clip both frames to their last common date (
align_date_col). - Collect index presence checks (extra indices on each side).
- Execute explicit per-column checks provided in
columns. - Apply a
default_checkto any remaining columns not explicitly covered (unlessdefault_checkisNone).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
columns
|
dict[str, ColumnCheck | None]
|
Mapping of column names (or regex patterns if the associated check has
|
required |
check_all
|
bool
|
All unspecified columns will be checked with :class: |
True
|
align_date_col
|
str
|
Optional date/datetime column (or index level) name used to clip both frames to their last common date before comparison. |
None
|
run(baseline, candidate, raise_on_failure=False)
¶
Execute all configured checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
baseline
|
DataFrame
|
Baseline frame. |
required |
candidate
|
DataFrame
|
Candidate frame to reconcile against the baseline. |
required |
raise_on_failure
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
RecResult
|
The full list of check results (passing + failing). When
|
recx.ColumnCheck(regex=False, **kwargs)
¶
Bases: ABC
check(baseline, candidate)
abstractmethod
¶
Evaluate the check for a single column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
baseline
|
Series
|
Baseline series. |
required |
candidate
|
Series
|
Candidate series (index-aligned with |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Frame of failing rows (may include additional diagnostic columns) or an empty frame if the check passed entirely. |
run(baseline, candidate, column)
¶
Execute the check for one (possibly regex) column pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
baseline
|
DataFrame
|
Baseline frame containing the columns. |
required |
candidate
|
DataFrame
|
Candidate frame. |
required |
column
|
str
|
Exact column name or regex pattern (if |
required |
Returns:
| Type | Description |
|---|---|
list[CheckResult]
|
One result per concrete column matched. |
recx.EqualCheck(regex=False, **kwargs)
¶
Bases: ColumnCheck
Check that baseline and candidate values are exactly equal.
NaNs (nulls) in the same position are treated as equal.
recx.AbsTolCheck(tol, sort=None, regex=False)
¶
Bases: ColumnCheck
Check absolute difference within tolerance.
The absolute error abs(baseline - candidate) must be <= tol or the
row is flagged. Matching nulls are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tol
|
float
|
Maximum permitted absolute difference. |
required |
sort
|
(asc, desc)
|
Sort order for failing rows by absolute error. |
'asc'
|
regex
|
bool
|
Treat the provided column spec as a regex pattern. |
False
|
recx.RelTolCheck(tol, sort=None, regex=False)
¶
Bases: ColumnCheck
Check relative difference within tolerance.
Relative error is computed as abs(baseline - candidate) / |candidate|.
A small stabiliser 1e-10 is used to avoid division by zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tol
|
float
|
Maximum permitted relative error. |
required |
sort
|
(asc, desc)
|
Sort order for failing rows by relative error. |
'asc'
|
regex
|
bool
|
Treat the provided column spec as a regex pattern. |
False
|
recx.CheckResult(failed_rows, check_name, total_rows, column=None, check_args=None, min_dots=5, disp_rows=20)
¶
Result of an individual column (or index) check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
failed_rows
|
DataFrame
|
Subset of rows (and associated columns) that failed the check. A zero-length frame indicates success. |
required |
check_name
|
str
|
Name of the check (usually the class name of the checker). |
required |
total_rows
|
int
|
Total number of rows evaluated by the check (denominator for failure ratios). |
required |
column
|
str
|
Column name the check was applied to ( |
None
|
check_args
|
dict
|
Mapping of argument names to values used to parameterise the check. |
None
|
min_dots
|
int
|
Minimum number of dots when formatting one-line summaries. |
5
|
outcome()
¶
Return formatted outcome string.
"PASSED" if there are no failing rows, otherwise a summary of the form
"[<count>/<total> (<pct>%)] FAILED".
one_liner(width=None)
¶
Return the result formatted as a single line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Target total width. If provided the line is padded with dots; if the width
is insufficient a |
None
|
Returns:
| Type | Description |
|---|---|
str
|
One-line summary |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
recx.RecResult(results, baseline, candidate)
¶
Represents the result of a diff between two DataFrames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[CheckResult]
|
All individual check results (passing and failing) in execution order. |
required |
summary(log=False)
¶
Print a summary.