Skip to main content

Generates comparison reports for pandas DataFrames.

Project description

pandascompare

Package version License

pandascompare is a Python package designed to compare DataFrame objects, enabling you to quickly identify the differences between two datasets.

Installation

pip install pandascompare

Main Features

The PandasCompare class compares any two DataFrame objects along the following dimensions:

  • Rows ➔ missing rows based on the join key(s) specified via the join_on argument.
  • Columns ➔ name differences or missing columns.
  • Values ➔ value mismatches in content or type.

Example Usage

Please refer to the documentation within the code for more information.

Imports

from pandascompare import PandasCompare

Create DataFrames

First, let's create two sample DataFrame objects to compare.

import pandas as pd
import numpy as np

# February Data
left_df = pd.DataFrame({
    'id': [1, 2, 3],
    'date': [pd.to_datetime('2024-02-29')] * 3,
    'first_name': ['Alice', 'Mike', 'John'],
    'amount': [10.5, 5.3, 33.77],
    })

# January Data
right_df = pd.DataFrame({
    'id': [1, 2, 9],
    'date': [pd.to_datetime('2024-01-31')] * 3,
    'first_name': ['Alice', 'Michael', 'Zachary'],
    'last_name': ['Jones', 'Smith', 'Einck'],
    'amount': [11.1, np.nan, 14],
    })

Compare DataFrames

Next, we will initialize a PandasCompare instance to perform the comparison. Please consult the in-code documentation for a comprehensive list of available arguments.

pc = PandasCompare(
    left_data=left_df,
    right_data=right_df,
    left_label='feb',
    right_label='jan',
    join_on='id',
    left_ref=['first_name'],
    include_delta=True,
    verbose=True,
    )

Export to Excel

Finally, let's export the compare report to an Excel file to view the results.

pc.to_excel()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandascompare-0.6.5.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandascompare-0.6.5-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pandascompare-0.6.5.tar.gz.

File metadata

  • Download URL: pandascompare-0.6.5.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.10 Windows/11

File hashes

Hashes for pandascompare-0.6.5.tar.gz
Algorithm Hash digest
SHA256 2e851bdd3415c188340db1d4eacaffd1a53c87027445f865267dec91465ddec4
MD5 8ae0bd7fac7545783632c014a453440f
BLAKE2b-256 a76d4159451114a22e5311a58fbca8df4856a2eb29c6b45f3df023565e08ad79

See more details on using hashes here.

File details

Details for the file pandascompare-0.6.5-py3-none-any.whl.

File metadata

  • Download URL: pandascompare-0.6.5-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.10 Windows/11

File hashes

Hashes for pandascompare-0.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fcb6d580841d4eebc03a1a2c714577bac0bf5cf9b18eca188615b5580a73b766
MD5 dc4c0f830240ed98d1c65b7245c0ec5d
BLAKE2b-256 3c04496a1eda512457b5eb3d7ea930783450aefc9b55322a6b12585934a3c2cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page