maintains_relationships
maintains_relationships(data, other_df, column)Function to help ensuring that set of values in selected column remains the same in both DataFrames. This helps to maintain referential integrity.
Parameters
Returns
| Name | Type | Description |
|---|---|---|
| PolarsLazyOrDataFrame | The original polars DataFrame or LazyFrame when the check passes |
Examples
>>> import polars as pl
>>> import pelage as plg
>>> initial_df = pl.DataFrame({"a": ["a", "b"]})
>>> final_df = pl.DataFrame({"a": ["a", "b"]})
>>> final_df.pipe(plg.maintains_relationships, initial_df, "a")
shape: (2, 1)
┌─────┐
│ a │
│ --- │
│ str │
╞═════╡
│ a │
│ b │
└─────┘
>>> final_df = pl.DataFrame({"a": ["a"]})>>> final_df.pipe(plg.maintains_relationships, initial_df, "a")
Traceback (most recent call last):
...
pelage.types.PolarsAssertError: Details
shape: (1, 2)
┌──────┬──────────┐
│ a ┆ a_in_ref │
│ --- ┆ --- │
│ str ┆ str │
╞══════╪══════════╡
│ null ┆ b │
└──────┴──────────┘
Error with the DataFrame passed to the check function:
--> Some values were removed from col 'a', see above!