Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pytest-ditto-pandas

Extension plugin for pytest-ditto for pandas DataFrame snapshots.

Use the following marks for their associated recorder:

  • @ditto.pandas.parquet
  • @ditto.pandas.json
  • @ditto.pandas.csv

Each mark is shorthand for @ditto.record("pandas.<format>").

Installation

pip install pytest-ditto[pandas]

Usage

import pandas as pd

import ditto


def awesome_fn_to_test(df: pd.DataFrame):
    df.loc[:, "a"] *= 2
    return df


# The following test uses pandas.DataFrame.to_parquet to write the data snapshot to the
# `.ditto` directory with filename:
# `<module>.test_fn_with_parquet_dataframe_snapshot@ab_dataframe~<hash>.pandas.parquet`.


@ditto.pandas.parquet
def test_fn_with_parquet_dataframe_snapshot(snapshot):
    input_data = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 9]})
    result = awesome_fn_to_test(input_data)
    pd.testing.assert_frame_equal(result, snapshot(result, key="ab_dataframe"))


# The following test uses pandas.DataFrame.to_json(orient="table") to write the data
# snapshot to the `.ditto` directory with filename:
# `<module>.test_fn_with_json_dataframe_snapshot@ab_dataframe~<hash>.pandas.json`.


@ditto.pandas.json
def test_fn_with_json_dataframe_snapshot(snapshot):
    input_data = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 9]})
    result = awesome_fn_to_test(input_data)
    pd.testing.assert_frame_equal(result, snapshot(result, key="ab_dataframe"))

Format notes

Only parquet round-trips a DataFrame exactly. JSON and CSV change some values or types on the way through, and a snapshot comparison then fails even though the code under test didn't change.

Format Index Values and dtypes
parquet preserved preserved
json preserved, except an index named index preserved, except numeric widths
csv single-level only; values re-parsed re-parsed from text

JSON (to_json(orient="table")):

  • An index named index is read back unnamed, and pandas warns that the name is not round-trippable.
  • Numeric columns are widened to 64 bits, so int8, int32 and uint16 come back as int64, and float32 as float64.

CSV keeps no type information, so every column and the index are parsed from text on load:

  • Strings that look like numbers become numbers: "001" is read back as 1.
  • Strings pandas treats as missing, such as "NA", "null" and "", become NaN.
  • dtypes are inferred again, so int32 comes back as int64, and categoricals come back as plain strings.
  • Only a single-level index is supported. DatetimeIndex, PeriodIndex, CategoricalIndex and MultiIndex are not.
  • A RangeIndex may come back as a plain integer index, depending on the pandas version. Pass check_index_type=False to pd.testing.assert_frame_equal to allow for that. It does not help with any of the changed values above.

Use @ditto.pandas.parquet for DataFrames that hit any of these cases.

Metadata

Release files for pytest-ditto-pandas 2.0.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-ditto-pandas 2.0.0rc1
File Size Uploaded
pytest_ditto_pandas-2.0.0rc1.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-ditto-pandas 2.0.0rc1
File Interpreter ABI Platform
pytest_ditto_pandas-2.0.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / pytest_ditto_pandas-2.0.0rc1.tar.gz

Download URL pytest_ditto_pandas-2.0.0rc1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d71672535521f416915768110a927db9b4dd1e145e9e5aa4d127fd23b31f29cd
BLAKE2b-256 checksum
How to use checksums
d04f25213c46f35ce81c47158effffb865ee2d86c1d5f8a5613e02e595f09c2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / pytest_ditto_pandas-2.0.0rc1-py3-none-any.whl

Download URL pytest_ditto_pandas-2.0.0rc1-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a715405f8f6799af74db60e8d1fc057f3c5e76849377c92eed7feb4a2992baf
BLAKE2b-256 checksum
How to use checksums
619a48f7895952502d62eb2db579911403f7f53fbf797693bced6200ebe8cd09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

2.0.0

2 release files

This release

2.0.0rc1 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page