Better approach could be
df = df.lazy().group_by('ColA').agg('ColB').with_columns(pl.col("ColB").list.unique())