# maintains_relationships { #pelage.maintains_relationships }

```python
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 {.doc-section .doc-section-parameters}

<code><span class="parameter-name">data</span><span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">[PolarsLazyOrDataFrame](`pelage.types.PolarsLazyOrDataFrame`)</span></code>

:   Dataframe after transformation

<code><span class="parameter-name">other_df</span><span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">[Union](`typing.Union`)\[[pl](`polars`).[DataFrame](`polars.DataFrame`), [pl](`polars`).[LazyFrame](`polars.LazyFrame`)\]</span></code>

:   Distant dataframe usually the one before transformation

<code><span class="parameter-name">column</span><span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">[str](`str`)</span></code>

:   Column to check for keys/ids

## Returns {.doc-section .doc-section-returns}

| Name   | Type                                                          | Description                                                      |
|--------|---------------------------------------------------------------|------------------------------------------------------------------|
|        | [PolarsLazyOrDataFrame](`pelage.types.PolarsLazyOrDataFrame`) | The original polars DataFrame or LazyFrame when the check passes |

## Examples {.doc-section .doc-section-examples}

```python
>>> 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"]})
```

```python
>>> 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!
```
