https://github.com/capitalone/datacompy
Pandas, Polars, Spark, and Snowpark DataFrame comparison for humans and more!
https://github.com/capitalone/datacompy
compare dask data data-science dataframes fugue numpy pandas polars pyspark python snowflake snowpark spark
Last synced: 6 days ago
JSON representation
Pandas, Polars, Spark, and Snowpark DataFrame comparison for humans and more!
- Host: GitHub
- URL: https://github.com/capitalone/datacompy
- Owner: capitalone
- License: apache-2.0
- Created: 2018-03-23T13:16:03.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2026-11-12T14:47:18.000Z (12 days ago)
- Last Synced: 2026-11-12T17:41:41.492Z (12 days ago)
- Topics: compare, dask, data, data-science, dataframes, fugue, numpy, pandas, polars, pyspark, python, snowflake, snowpark, spark
- Language: Python
- Homepage: https://capitalone.github.io/datacompy/
- Size: 14.9 MB
- Stars: 669
- Watchers: 19
- Forks: 178
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
- Roadmap: ROADMAP.rst
Awesome Lists containing this project
- awesome-datascience - datacompy - DataComPy is a package to compare two Pandas DataFrames. (The Data Science Toolbox / Comparison)
- fucking-awesome-machine-learning - DataComPy - A library to compare Pandas, Polars, and Spark data frames. It provides stats and lets users adjust for match accuracy. (Python)
- awesome-machine-learning - DataComPy - A library to compare Pandas, Polars, and Spark data frames. It provides stats and lets users adjust for match accuracy. (Python)
- fucking-awesome-datascience - datacompy - DataComPy is a package to compare two Pandas DataFrames. (The Data Science Toolbox / Comparison)
- awesome-data-engineering - datacompy - A Python library that facilitates the comparison of two DataFrames in Pandas, Polars, Spark and more. The library goes beyond basic equality checks by providing detailed insights into discrepancies at both row and column levels. (Data Comparison)
- awesome-machine-learning - DataComPy - A library to compare Pandas, Polars, and Spark data frames. It provides stats and lets users adjust for match accuracy. (Python / General-Purpose Machine Learning)
- awesome-python-data-science - DataComPy - \- A library to compare Pandas, Polars, and Spark data frames. It provides stats and lets users adjust for match accuracy. (Data Validation)
README
# DataComPy

[](https://github.com/astral-sh/ruff)
[](https://badge.fury.io/py/datacompy)
[](https://anaconda.org/conda-forge/datacompy)

DataComPy is a package to compare two DataFrames (or tables) such as Pandas, Spark, Polars, and
even Snowflake. Originally it was created to be something of a replacement
for SAS's ``PROC COMPARE`` for Pandas DataFrames with some more functionality than
just ``Pandas.DataFrame.equals(Pandas.DataFrame)`` (in that it prints out some stats,
and lets you tweak how accurate matches have to be). Supported types include:
- Pandas
- Polars
- Spark (classic and Spark Connect)
- Snowflake
> [!IMPORTANT]
> datacompy has released `v1`. The `v0.19.x` line is no longer supported — users should upgrade to `v1` going forward.
> The `support/0.19.x` branch is archived and will only receive critical security fixes on a best-effort basis; no new features or regular maintenance will be provided.
> All active development targets `main`.
## Quick Installation
```shell
pip install datacompy
```
or
```shell
conda install datacompy
```
### Installing extras
If you would like to use Spark or any other backends please make sure you install via extras:
```shell
pip install datacompy[spark]
pip install datacompy[snowflake]
```
## Supported backends
- Pandas: ([See documentation](https://capitalone.github.io/datacompy/pandas_usage.html))
- Spark: ([See documentation](https://capitalone.github.io/datacompy/spark_usage.html))
- Polars: ([See documentation](https://capitalone.github.io/datacompy/polars_usage.html))
- Snowflake/Snowpark: ([See documentation](https://capitalone.github.io/datacompy/snowflake_usage.html))
## Command Line Interface
DataComPy ships a `datacompy` command, so ad hoc checks and CI pipelines do not
need a throw-away script ([see documentation](https://capitalone.github.io/datacompy/cli.html)):
```bash
# Compare two files and print a report
datacompy compare --left before.csv --right after.csv --on id
# Fail a build on any difference, with a JSON report saved as an artifact
datacompy compare \
--left before.parquet --right after.parquet \
--on account_id,as_of_date \
--abs-tol balance=0.01 \
--max-unequal-rows 0 \
--report-format json --output reports/diff.json --quiet
```
It exits `0` when the datasets match, `1` when they differ, and `2` on error.
CSV, Parquet, and JSON inputs are supported on the pandas, polars, and Spark
backends, including tab separated CSV via a `.tsv` extension, and Snowflake
tables can be compared in place.
## Programmatic Report Access
Every compare object exposes `build_report_data()` which returns a typed
[`ReportData`](https://capitalone.github.io/datacompy/report_api.html) object
— useful for dashboards, JSON export, or custom rendering without relying on
the string report:
```python
import pandas as pd
from datacompy import PandasCompare
df1 = pd.DataFrame({"id": [1, 2, 3], "val": [10, 20, 30]})
df2 = pd.DataFrame({"id": [1, 2, 3], "val": [10, 99, 30]})
compare = PandasCompare(df1, df2, join_columns="id")
# Access structured data directly
data = compare.build_report_data()
print(data.row_summary.unequal_rows) # 1
print(data.mismatch_stats.stats[0].column) # 'val'
# Render / export — methods live on ReportData itself
print(data.render()) # same text as compare.report()
data.save("report.html") # HTML file
data.to_dict() # JSON-serializable dict
```
See the [Report API documentation](https://capitalone.github.io/datacompy/report_api.html) for the full reference.
## Contributors
We welcome and appreciate your contributions! Before we can accept any contributions, we ask that you please be sure to
sign the [Contributor License Agreement (CLA)](https://cla-assistant.io/capitalone/datacompy).
To run the CI test matrix locally, including the Spark and Spark Connect tracks without a hand-managed JDK,
see the [Developer Instructions](https://capitalone.github.io/datacompy/developer_instructions.html).
This project adheres to the [Open Source Code of Conduct](https://developer.capitalone.com/resources/code-of-conduct/).
By participating, you are expected to honor this code.