# mutually_exclusive_ranges { #pelage.checks.mutually_exclusive_ranges }

`checks.mutually_exclusive_ranges(data, low_bound, high_bound, group_by=None)`

Ensure that the specified columns contains no overlapping intervals.

## Parameters

<code><span class="parameter-name">data</span><span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">PolarsLazyOrDataFrame</span></code>

:   Data to check

<code><span class="parameter-name">low_bound</span><span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">str</span></code>

:   Name of column containing the lower bound of the interval

<code><span class="parameter-name">high_bound</span><span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">str</span></code>

:   Name of column containing the higher bound of the interval

<code><span class="parameter-name">group_by</span><span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">IntoExpr \| Iterable\[IntoExpr\]</span> <span class="parameter-default-sep">=</span> <span class="parameter-default">None</span></code>

:   Parameter compatible with `.over()` function to split the check by groups,
    by default None

## Returns

| Type                  | Description                                                      |
|-----------------------|------------------------------------------------------------------|
| PolarsLazyOrDataFrame | The original polars DataFrame or LazyFrame when the check passes |

## Examples

```python
>>> import polars as pl
>>> import pelage as plg
>>> df = pl.DataFrame(
...     [
...         [1, 2],
...         [3, 4],
...     ],
...     schema=["a", "b"], orient="row"
... )
>>> df.pipe(plg.mutually_exclusive_ranges, low_bound="a", high_bound="b")
shape: (2, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1   ┆ 2   │
│ 3   ┆ 4   │
└─────┴─────┘
>>> df = pl.DataFrame(
...     [
...         [1, 3],
...         [2, 4],
...         [5, 7],
...         [6, 8],
...         [9, 9],
...     ],
...     schema=["a", "b"],
...     orient="row",
... )
>>> df.pipe(plg.mutually_exclusive_ranges, low_bound="a", high_bound="b")
Traceback (most recent call last):
...
pelage.checks.PolarsAssertError: Details
shape: (4, 3)
┌───────┬─────┬─────┐
│ index ┆ a   ┆ b   │
│ ---   ┆ --- ┆ --- │
│ u32   ┆ i64 ┆ i64 │
╞═══════╪═════╪═════╡
│ 0     ┆ 1   ┆ 3   │
│ 1     ┆ 2   ┆ 4   │
│ 2     ┆ 5   ┆ 7   │
│ 3     ┆ 6   ┆ 8   │
└───────┴─────┴─────┘
Error with the DataFrame passed to the check function:
--> There were overlapping intervals:
DataFrame was sorted by: ['a', 'b'],
Interval columns: low_bound='a', high_bound='b'
```