tabulardelta.tabulardelta module

class tabulardelta.tabulardelta.ChangedColumn(*args, **kwargs)[source]

Bases: MatchedColumn, Protocol, Iterable[ChangedValue]

Represents changes within the same column between the old and new table.

Use len() to get the total number of changed values.

Since this is an Iterable[ChangedValue], it may contain examples of the changes:

A ChangedValue can represent multiple occurrences of the same values changing.

There might be fewer examples than the total number of changes (returned by len()).

Attributes:
new

The column in the new table.

old

The column in the old table.

Methods

__len__() -> int

Total number of changes.

__iter__() -> Iterator[ChangedValue]

Examples of value changes.

class tabulardelta.tabulardelta.ChangedValue(*args, **kwargs)[source]

Bases: Protocol

Represents a change of a value.

Attributes:
count

(Positive) number of rows containing this change.

example_join_columns

Mapping from column names to values represents an example row where this change occurred.

new

New value after the change.

old

Previous value before the change.

property count: int

(Positive) number of rows containing this change.

property example_join_columns: Mapping[str, Any]

Mapping from column names to values represents an example row where this change occurred.

property new: Any

New value after the change.

property old: Any

Previous value before the change.

class tabulardelta.tabulardelta.Column(*args, **kwargs)[source]

Bases: Protocol

Represents a column in a table.

Attributes:
name

Name of the column.

type

Data type of the column.

property name: str

Name of the column.

property type: str

Data type of the column.

class tabulardelta.tabulardelta.ColumnDelta(*args, **kwargs)[source]

Bases: Protocol

Generic collection of information about columns, types and their changes.

Attributes:
added

Metadata of added columns (only in new table).

comparable_type_changed

Metadata of columns with changed but comparable data types.

differences

Changed values of comparable columns.

incomparable_type_changed

Columns with changed and incomparable data types, including value changes.

joined

Metadata of columns used to join the old and new table.

new

Metadata of columns in the new table.

old

Metadata of columns in the old table.

removed

Metadata of removed columns (only in old table).

renamed

Metadata of renamed columns (matched using values and types).

property added: Sequence[Column]

Metadata of added columns (only in new table).

property comparable_type_changed: Sequence[MatchedColumn]

Metadata of columns with changed but comparable data types.

property differences: Sequence[ChangedColumn]

Changed values of comparable columns.

property incomparable_type_changed: Sequence[ChangedColumn]

Columns with changed and incomparable data types, including value changes.

All values are assumed to be different.

property joined: Sequence[MatchedColumn]

Metadata of columns used to join the old and new table.

property new: Sequence[Column]

Metadata of columns in the new table.

property old: Sequence[Column]

Metadata of columns in the old table.

property removed: Sequence[Column]

Metadata of removed columns (only in old table).

property renamed: Sequence[MatchedColumn]

Metadata of renamed columns (matched using values and types).

class tabulardelta.tabulardelta.MatchedColumn(*args, **kwargs)[source]

Bases: Protocol

Metadata of the same column in the old and new table.

Attributes:
new

The column in the new table.

old

The column in the old table.

property new: Column

The column in the new table.

property old: Column

The column in the old table.

class tabulardelta.tabulardelta.RowDelta(*args, **kwargs)[source]

Bases: Protocol

Generic collection of information about rows.

Attributes:
added

Added rows (only in new table).

equal

Equal rows (joined and all columns unchanged).

new

Rows in the new table.

old

Rows in the old table.

removed

Removed rows (only in old table).

unequal

Unequal rows (joined but at least one column changed).

property added: Rows

Added rows (only in new table).

property equal: Rows

Equal rows (joined and all columns unchanged).

property new: Rows

Rows in the new table.

property old: Rows

Rows in the old table.

property removed: Rows

Removed rows (only in old table).

property unequal: Rows

Unequal rows (joined but at least one column changed).

class tabulardelta.tabulardelta.Rows(*args, **kwargs)[source]

Bases: Protocol, Iterable[Mapping[str, Any]]

Represents multiple rows. Use len() to get the number of represented rows.

Since this is an Iterable[Mapping[str, Any]], it may contain examples of the represented rows:

A Mapping[str, Any] maps column names to values of one row.

There might be fewer examples than the number represented rows (returned by len()).

Methods

__len__() -> int

Number of represented rows.

__iter__() -> Iterator[Mapping[str, Any]]

Examples of represented rows.

class tabulardelta.tabulardelta.TabularDelta(*args, **kwargs)[source]

Bases: Protocol

Generic collection of information gathered by one table comparison.

Contains metadata about the comparison, RowDelta and ColumnDelta.

Attributes:
cols

Column comparison containing information about columns, types, and value changes.

errors

Errors collected during the comparison.

info

Additional information collected during the comparison.

name

Name of the new table and therefore the comparison.

old_name

Optional name of the old table.

rows

Row comparison containing information about row changes and examples.

warnings

Warnings collected during the comparison.

property cols: ColumnDelta

Column comparison containing information about columns, types, and value changes.

property errors: Sequence[str]

Errors collected during the comparison.

property info: Sequence[str]

Additional information collected during the comparison.

property name: str

Name of the new table and therefore the comparison.

property old_name: str | None

Optional name of the old table.

property rows: RowDelta

Row comparison containing information about row changes and examples.

property warnings: Sequence[str]

Warnings collected during the comparison.