I have some data with 2 columns in the following format:
import polars as pl
df = pl.from_repr("""
┌──────┬─────────┐
│ nums ┆ letters │
│ --- ┆ --- │
│ i64 ┆ str │
╞══════╪═════════╡
│ 160 ┆ B │
│ 540 ┆ I │
│ 550 ┆ I │
│ 590 ┆ B │
│ 370 ┆ I │
└──────┴─────────┘
""")
And I want to merge the cells that come in the form of B in addition to consecutive I's (i.e. BI*):
shape: (2, 1)
┌─────────────────┐
│ nums │
│ --- │
│ list[i64] │
╞═════════════════╡
│ [160, 540, 550] │
│ [590, 370] │
└─────────────────┘
How can I achieve something like this with polars?