proccompy 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ *.egg-info/
5
+ .pytest_cache/
6
+ dist/
7
+ build/
8
+ .idea/
9
+ .vscode/
10
+ scratch/
11
+ scratch/
12
+ data/
13
+ scratch/
14
+ data/
@@ -0,0 +1,129 @@
1
+ # Changelog
2
+
3
+ All notable changes to proccompy are documented here.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.4.1] — 2026-05-25
9
+
10
+ ### Fixed
11
+ - **Declared `pyarrow` as a required dependency.** It's needed at runtime
12
+ for polars↔DuckDB data exchange but was missing from `pyproject.toml`
13
+ in 0.4.0. Users installing from PyPI in a clean environment would hit
14
+ `ModuleNotFoundError: No module named 'pyarrow'` on the first
15
+ `compare()` call. Detected during TestPyPI launch verification.
16
+
17
+ ## [0.4.0] — 2026-05-25
18
+
19
+ First public release on PyPI.
20
+
21
+ ### Added
22
+ - PyPI metadata: keywords, trove classifiers, project URLs pointing to GitHub.
23
+
24
+ ### Notes
25
+ - API and CLI surface are unchanged from 0.3.1; this is purely a packaging
26
+ release for PyPI launch.
27
+
28
+ ## [0.3.1] — 2026-05-25
29
+
30
+ ### Added
31
+ - **Parquet directory input** in the CLI. Pass a folder of `part_*.parquet`
32
+ files (Spark/Athena-style output) as either `BASE` or `COMPARE`; polars
33
+ reads them as one logical dataset.
34
+ - **Hive partitioning** is on by default for directory input — subdirectories
35
+ like `year=2024/month=01/` produce `year` and `month` columns usable as
36
+ ID columns. Disable with `--no-hive`.
37
+
38
+ ### Tests
39
+ - 11 new tests covering simple multi-file directories, Hive-partitioned
40
+ directories, dir-vs-file comparisons, and schema-mismatch errors.
41
+
42
+ ## [0.3.0] — 2026-05-25
43
+
44
+ ### Added
45
+ - **`proccompy` command-line interface** for shell-level use, with no
46
+ Python required.
47
+ - Reads parquet, CSV, and TSV files (format inferred from extension,
48
+ overridable with `--format`).
49
+ - Per-column tolerances via repeated `--tolerance "col=method:value"`
50
+ flags (`abs`, `pct`, `exact`).
51
+ - Multi-column ID specification via comma-separated `--id "col1,col2"`.
52
+ - Structured output flags: `--lst`, `--text`, `--summary-csv`,
53
+ `--diff-parquet`.
54
+ - Exit code **0** if datasets match (within tolerances), **1** if they
55
+ differ — usable as a CI/cron validation gate.
56
+ - `click >= 8.0` dependency for the CLI.
57
+
58
+ ### Tests
59
+ - 36 new CLI tests using `click.testing.CliRunner`.
60
+
61
+ ## [0.2.1] — 2026-05-24
62
+
63
+ ### Added
64
+ - **Per-column difference statistics** on `CompareResult.summary()`:
65
+ - `mean_diff`, `std_diff`, `min_diff` (signed)
66
+ - `n_base_greater`, `n_compare_greater` (directional bias counts)
67
+ - New `.lst` section: "Statistics for Numeric Differences" rendered
68
+ beneath the variables-with-unequal-values table.
69
+ - Statistics are computed over **matched non-null observation pairs**,
70
+ matching SAS PROC COMPARE `STATS` semantics — independent of whether
71
+ tolerance accepted the diff.
72
+
73
+ ### Tests
74
+ - 15 new tests covering bias direction, mixed-sign drift, single-row
75
+ edge cases, and stats-when-within-tolerance.
76
+
77
+ ## [0.2.0] — 2026-05-23
78
+
79
+ ### Added
80
+ - **`CompareResult.to_lst()`** — SAS-style `.lst` report writer:
81
+ - 132-column fixed width, ASCII only
82
+ - Form-feed page breaks between major sections
83
+ - Page headers with procedure name, datetime, page number
84
+ - Per-observation comparison detail (Base / Compare / Diff / % Diff)
85
+ - Capped at `n_sample` observations (default 50)
86
+ - **`CompareResult.to_text()`** — write the terminal-style report to a
87
+ UTF-8 text file.
88
+
89
+ ### Tests
90
+ - 20 new tests for `.lst` rendering, ASCII compliance, page-break
91
+ conventions, and edge cases.
92
+
93
+ ## [0.1.1] — 2026-05-22
94
+
95
+ Initial release.
96
+
97
+ ### Added
98
+ - **DuckDB-based comparison engine.** `FULL OUTER JOIN` keyed on
99
+ `id_columns` with per-column unequal expressions. Streams on disk,
100
+ not memory-bound.
101
+ - **Per-column tolerances**: `T.exact()`, `T.absolute(value)`,
102
+ `T.percent(value)`.
103
+ - **Null-safe join** via SQL `IS NOT DISTINCT FROM`. No sentinel-string
104
+ hacks.
105
+ - **Strict duplicate-key detection** — raises `ValueError` with counts
106
+ per side.
107
+ - **Pandas, Polars, and DuckDB relation input**.
108
+ - `CompareResult` accessor methods:
109
+ - `summary()` — per-column polars DataFrame
110
+ - `unequal_rows()` / `base_only_rows()` / `compare_only_rows()`
111
+ - `diff_dataset()` — SAS `OUT=` equivalent with `_TYPE_` ∈ {BASE,
112
+ COMPARE, DIF, PERCENT} and `_OBS_`
113
+ - `joined()` — full joined frame for custom analysis
114
+ - `assert_matches()` — raises `AssertionError` with structured
115
+ failure detail, for pytest / CI use
116
+ - `report()` — terminal-style structured report
117
+
118
+ ### Tests
119
+ - 21 tests covering identical frames, value diffs, tolerances, nulls,
120
+ row presence, duplicate-key detection, dtype mismatches, multi-column
121
+ IDs, pandas input, OUT= dataset, and report rendering.
122
+
123
+ [0.4.1]: https://github.com/kulbshar/proccompy/releases/tag/v0.4.1
124
+ [0.4.0]: https://github.com/kulbshar/proccompy/releases/tag/v0.4.0
125
+ [0.3.1]: https://github.com/kulbshar/proccompy/releases/tag/v0.3.1
126
+ [0.3.0]: https://github.com/kulbshar/proccompy/releases/tag/v0.3.0
127
+ [0.2.1]: https://github.com/kulbshar/proccompy/releases/tag/v0.2.1
128
+ [0.2.0]: https://github.com/kulbshar/proccompy/releases/tag/v0.2.0
129
+ [0.1.1]: https://github.com/kulbshar/proccompy/releases/tag/v0.1.1
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,284 @@
1
+ Metadata-Version: 2.4
2
+ Name: proccompy
3
+ Version: 0.4.1
4
+ Summary: Structured comparison reports for tabular data in Python — modeled on SAS PROC COMPARE.
5
+ Project-URL: Homepage, https://github.com/kulbshar/proccompy
6
+ Project-URL: Repository, https://github.com/kulbshar/proccompy
7
+ Project-URL: Issues, https://github.com/kulbshar/proccompy/issues
8
+ Project-URL: Changelog, https://github.com/kulbshar/proccompy/blob/main/CHANGELOG.md
9
+ Project-URL: Documentation, https://github.com/kulbshar/proccompy#readme
10
+ Author-email: Kulbhushan Sharma <sharma.kul.1982@gmail.com>
11
+ License: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: comparison,data-engineering,dataframe,duckdb,etl,pandas,polars,proc-compare,sas,validation
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Information Technology
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: License :: OSI Approved :: Apache Software License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
27
+ Classifier: Topic :: Software Development :: Quality Assurance
28
+ Classifier: Topic :: Software Development :: Testing
29
+ Classifier: Topic :: Utilities
30
+ Classifier: Typing :: Typed
31
+ Requires-Python: >=3.10
32
+ Requires-Dist: click>=8.0
33
+ Requires-Dist: duckdb>=0.10.0
34
+ Requires-Dist: polars>=1.0.0
35
+ Requires-Dist: pyarrow>=10.0.0
36
+ Provides-Extra: pandas
37
+ Requires-Dist: pandas>=2.0.0; extra == 'pandas'
38
+ Provides-Extra: test
39
+ Requires-Dist: pandas>=2.0.0; extra == 'test'
40
+ Requires-Dist: pytest>=7.0; extra == 'test'
41
+ Description-Content-Type: text/markdown
42
+
43
+ # proccompy
44
+
45
+ **Structured comparison reports for tabular data in Python.**
46
+
47
+ If you've ever needed to prove that two DataFrames hold the same data — after a pipeline rewrite, between source and ETL output, across a database migration, or in a daily regression check — you've probably found that `pandas.DataFrame.compare()` shows you cell-level diffs, `assert_frame_equal` gives you pass/fail, and neither tells you the thing you actually want to know: **where do they differ, by how much, in which direction, and does it matter?**
48
+
49
+ proccompy produces a structured diagnostic report that answers those questions in the order you'd ask them. It's modeled on SAS PROC COMPARE — a 40-year-old procedure that data analysts trust because it makes "what changed?" a 30-second scan instead of an afternoon of investigation.
50
+
51
+ ```python
52
+ import polars as pl
53
+ import proccompy as pc
54
+ from proccompy import T
55
+
56
+ base = pl.read_parquet("production.parquet")
57
+ rewrite = pl.read_parquet("new_implementation.parquet")
58
+
59
+ result = pc.compare(
60
+ base, rewrite,
61
+ id_columns="account_id",
62
+ tolerances={
63
+ "dollar_amount": T.absolute(0.01), # rounding-level diffs are OK
64
+ "rate": T.percent(0.001), # but >0.1% relative is not
65
+ },
66
+ )
67
+
68
+ result.to_lst("validation.lst") # SAS-style listing for archival / review
69
+ result.assert_matches() # raises AssertionError if they don't — for CI
70
+ ```
71
+
72
+ ## Why this exists
73
+
74
+ The Python ecosystem has many ways to *find* differences between two DataFrames. What it doesn't have is a structured report that helps you *interpret* them.
75
+
76
+ - `pandas.DataFrame.compare()` returns a multi-index DataFrame of cell-level diffs. No summary, no row-presence breakdown, no statistics.
77
+ - `pandas.testing.assert_frame_equal` raises on first difference. Tells you something is wrong, not what.
78
+ - [`datacompy`](https://github.com/capitalone/datacompy) has a report, but it's a flat text dump optimized for a single screen. No per-column difference statistics, no SAS conventions, no `.lst` output, no streaming/out-of-core support.
79
+ - Schema-validation tools (Great Expectations, Pandera) check one frame against rules. They don't compare two frames.
80
+
81
+ The result: every team building a data pipeline ends up writing their own ad-hoc comparison script. That script's report is always a little worse than PROC COMPARE's because PROC COMPARE has had four decades of refinement.
82
+
83
+ proccompy brings that report to Python natively — running on polars, pandas, or DuckDB; pluggable into pytest; producing `.lst` files SAS analysts already know how to read.
84
+
85
+ ## Who is this for
86
+
87
+ **Data engineers doing pipeline validation.** You're rewriting an implementation, migrating a database, or proving that yesterday's output matches today's. You want tolerance per column (because floating-point drift isn't "wrong"), the differences summarized and broken down, and a structured object you can assert on in CI.
88
+
89
+ **ETL teams comparing output to source.** You need a recurring check that your pipeline faithfully reproduces source data, with the diagnostic depth to tell rounding drift from real corruption.
90
+
91
+ **SAS analysts who miss the PROC COMPARE listing.** You moved to Python (willingly or not) and want a comparison report your boss will accept — `.lst` format, with the same sections you've read for 20 years.
92
+
93
+ **Testing frameworks for data pipelines.** You're building (or using) dbt tests, custom assertion harnesses, regression suites. proccompy gives you a clean programmatic `CompareResult` to embed: structured fields, pytest-friendly.
94
+
95
+ ## What the report tells you
96
+
97
+ A real PROC COMPARE listing isn't arbitrary — it's a diagnostic protocol. Each section answers a question, in the order you'd ask it:
98
+
99
+ 1. **Dataset Summary** — are we comparing what I think we're comparing?
100
+ 2. **Variables Summary** — do the schemas match?
101
+ 3. **Observation Summary** — do the same keys exist on both sides?
102
+ 4. **Values Comparison Summary** — how broken is this, in one glance?
103
+ 5. **Variables with Unequal Values** — which columns are responsible?
104
+ 6. **Statistics for Numeric Differences** — bias direction, spread, magnitude
105
+ 7. **Comparison Results for Observations** — show me the actual numbers
106
+
107
+ You can scan a 50-page `.lst` in 30 seconds and decide whether to investigate or close the ticket. That's the value.
108
+
109
+ ## Install
110
+
111
+ ```bash
112
+ pip install proccompy
113
+ ```
114
+
115
+ Requires Python 3.10+. Pulls in `duckdb` and `polars`. Add `pandas` only if you need it as input.
116
+
117
+ ## Usage
118
+
119
+ ### The basic comparison
120
+
121
+ ```python
122
+ import polars as pl
123
+ import proccompy as pc
124
+
125
+ base = pl.DataFrame({"id": [1, 2, 3], "x": [10.0, 20.0, 30.0]})
126
+ compare = pl.DataFrame({"id": [1, 2, 3], "x": [10.0, 20.5, 30.0]})
127
+
128
+ result = pc.compare(base, compare, id_columns="id")
129
+
130
+ result.matches # → False
131
+ result.summary() # → per-column polars DataFrame
132
+ print(result.report()) # → terminal-style report
133
+ ```
134
+
135
+ Inputs can be polars DataFrames, pandas DataFrames, or DuckDB relations.
136
+
137
+ ### Tolerances per column
138
+
139
+ ```python
140
+ from proccompy import T
141
+
142
+ result = pc.compare(
143
+ base, compare,
144
+ id_columns="account_id",
145
+ tolerances={
146
+ "dollar_amount": T.absolute(0.01), # within 1 cent → equal
147
+ "rate": T.percent(0.001), # within 0.1% relative → equal
148
+ "category": T.exact(), # exact match required (default)
149
+ },
150
+ )
151
+ ```
152
+
153
+ Three tolerance types: `T.exact()`, `T.absolute(value)`, `T.percent(value)`. Per-column. Defaults to exact for columns you don't specify.
154
+
155
+ ### Multiple ID columns
156
+
157
+ ```python
158
+ result = pc.compare(
159
+ base, compare,
160
+ id_columns=["sector", "naics_code", "year"],
161
+ )
162
+ ```
163
+
164
+ ### SAS-style .lst output
165
+
166
+ ```python
167
+ result.to_lst("validation.lst")
168
+ ```
169
+
170
+ Produces a paginated, fixed-width, ASCII-only `.lst` file with form-feed page breaks and SAS-style headers. Looks like real PROC COMPARE output. Open it in any text editor; attach it to a ticket; share it with anyone who used to write SAS.
171
+
172
+ ### Assertion for CI
173
+
174
+ ```python
175
+ def test_pipeline_rewrite_matches_production():
176
+ base = pl.read_parquet("expected.parquet")
177
+ actual = run_pipeline()
178
+ pc.compare(base, actual, id_columns="id").assert_matches()
179
+ ```
180
+
181
+ Raises `AssertionError` with structured per-column failure detail. Drops into any pytest suite.
182
+
183
+ ### The structured result
184
+
185
+ `CompareResult` exposes everything as DataFrames you can post-process:
186
+
187
+ ```python
188
+ result.summary() # per-column summary
189
+ result.unequal_rows() # both-side rows with at least one diff
190
+ result.base_only_rows() # rows only in base
191
+ result.compare_only_rows() # rows only in compare
192
+ result.diff_dataset() # SAS OUT= equivalent: BASE / COMPARE / DIF / PERCENT
193
+ result.joined() # full joined frame for custom analysis
194
+ ```
195
+
196
+ ### Command line
197
+
198
+ proccompy installs a `proccompy` console script for shell-level use — no Python required:
199
+
200
+ ```bash
201
+ # Simple: compare two parquet files, report to stdout, exit 0 or 1
202
+ proccompy expected.parquet actual.parquet --id account_id
203
+
204
+ # With tolerances and multiple ID columns
205
+ proccompy old.csv new.csv --id "sector,year" \
206
+ --tolerance "amount=abs:0.01" \
207
+ --tolerance "rate=pct:0.001"
208
+
209
+ # Pipe everything to disk for archival / CI artifacts
210
+ proccompy a.parquet b.parquet --id id \
211
+ --lst report.lst \
212
+ --summary-csv summary.csv \
213
+ --diff-parquet diffs.parquet \
214
+ --quiet
215
+ ```
216
+
217
+ Exit codes: **0** if the datasets match (within any specified tolerances), **1** if they differ in any compared value, row presence, or column overlap. Use as a CI gate:
218
+
219
+ ```bash
220
+ proccompy expected.parquet actual.parquet --id id --quiet && deploy.sh
221
+ ```
222
+
223
+ Supports parquet, CSV, and TSV input; format is inferred from extension or set with `--format`. Run `proccompy --help` for the full reference.
224
+
225
+ ### Per-column difference statistics
226
+
227
+ For numeric columns, the summary includes diagnostic statistics computed over matched non-null pairs (SAS PROC COMPARE STATS semantics):
228
+
229
+ ```python
230
+ summary = result.summary()
231
+ # Columns: column, base_dtype, compare_dtype, n_compared, n_unequal,
232
+ # n_null_mismatch, max_abs_diff, mean_diff, std_diff, min_diff,
233
+ # n_base_greater, n_compare_greater
234
+ ```
235
+
236
+ These let you distinguish three failure modes that `max_abs_diff` alone can't:
237
+
238
+ | mean_diff | std_diff | n_base_gt | n_compare_gt | Diagnosis |
239
+ |---|---|---|---|---|
240
+ | `+2.0` | `0.0` | `0` | `195` | Constant positive offset (unit conversion?) |
241
+ | `0.0` | `5.1` | `10` | `10` | No bias but high spread (real drift) |
242
+ | `+0.1` | `0.0` | `0` | `195` | Small uniform drift, within tolerance |
243
+
244
+ ## Alternatives — when to use what
245
+
246
+ | | Best for | Limitation |
247
+ |---|---|---|
248
+ | `pandas.DataFrame.compare()` | Quick cell-level diff in a notebook | No summary, no report, no tolerance |
249
+ | `pandas.testing.assert_frame_equal` | Strict pass/fail in tests | Stops at first diff, no diagnostic depth |
250
+ | [`datacompy`](https://github.com/capitalone/datacompy) | Flat text report for one-screen review | Memory-bound, global-only tolerance, no `.lst`, no per-column diff stats |
251
+ | Great Expectations, Pandera | Schema/distribution validation on one frame | Don't compare two frames |
252
+ | **proccompy** | Structured diagnostic report for pipeline validation | Out-of-core via DuckDB engine only (Spark engine not yet implemented) |
253
+
254
+ If you need a one-line cell diff, use `pandas.compare()`. If you need a structured report you can attach to a PR, a Jira ticket, or a SAS analyst's email, use proccompy.
255
+
256
+ ## What's under the hood
257
+
258
+ - **DuckDB engine.** The comparison is a `FULL OUTER JOIN` keyed on `id_columns` with per-column unequal expressions. DuckDB streams this on disk, so you're not memory-bound even for hundreds of millions of rows.
259
+ - **Polars I/O.** Frames register zero-copy via Arrow; results come back as polars DataFrames.
260
+ - **Null-safe.** Uses SQL `IS NOT DISTINCT FROM` semantics. No sentinel-string hacks.
261
+ - **Strict duplicate-key detection.** If your ID columns aren't unique, you'll get a clear error with counts, not silent wrong answers.
262
+ - **Apache 2.0 licensed.**
263
+
264
+ ## Roadmap
265
+
266
+ - **v0.4** — BY groups (stratified comparison summaries)
267
+ - **v0.5** — `result.to_html()` self-contained HTML report
268
+ - **v1.0** — pytest plugin, full documentation site, PyPI release
269
+
270
+ Stable: top-level `pc.compare()`, `T.exact/absolute/percent`, `CompareResult` accessor methods, `.lst` format, CLI flags and exit codes.
271
+
272
+ Subject to change: `_joined` internal structure, exact `.lst` column widths.
273
+
274
+ ## Contributing
275
+
276
+ Issues and PRs welcome. Run the test suite with `pytest tests/`. Currently 92 tests; please add one for any new behavior.
277
+
278
+ ## License
279
+
280
+ Apache 2.0. See `LICENSE`.
281
+
282
+ ---
283
+
284
+ Built by [Kulbhushan Sharma](https://github.com/kulbshar) because the PROC COMPARE report was the SAS feature I missed most after switching to Python.