Skip to main content

pytest-ditto-pandas

A pytest-ditto plugin for pandas DataFrame and Series snapshots.

Documentation

Installation

pip install "pytest-ditto[pandas]"

It needs pandas 2.2 or later and pyarrow 16.1.0 or later.

Marks

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

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

Use @ditto.pandas.parquet unless you need a snapshot you can read as text. It's the only format that keeps dtypes and values exactly, for data Arrow can represent. JSON and CSV change some data on the way through, including rounding floats without failing the test; see the format notes in the documentation.

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"))

Metadata

Release files for pytest-ditto-pandas 2.0.0

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.0
File Size Uploaded
pytest_ditto_pandas-2.0.0.tar.gz 6.7 kB Details

Built distribution (wheel)

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

Total release size: 13.1 kB

Release files / pytest_ditto_pandas-2.0.0.tar.gz

Download URL pytest_ditto_pandas-2.0.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9a615028ce714f2653c9a898c8270dd09632b5869b1c3d199b727233d50249b5
BLAKE2b-256 checksum
How to use checksums
85bea97581c0d586c55dbd60aaa47eb261a5a1f96fc8f9b90670b980f6d5ddcf
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 Oct 7, 2026.

Transparency log

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

Download URL pytest_ditto_pandas-2.0.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
363584a337c15bf980dcb821cbfeac2a7e1806f10d4c8468f13bac3ee6fa62dd
BLAKE2b-256 checksum
How to use checksums
f9b9796c55f5e3a7f051d5e5781b70878699e541802e996bac61b0c42301f712
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 Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 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