Код: Выделить всё
def has_duplicates_early_exit(df: pl.LazyFrame, subset: list[str]) -> bool:
"""Can exit early when first duplicate is found"""
return df.select(
pl.struct(subset).is_duplicated().any()
).collect().item()
Подробнее здесь: https://stackoverflow.com/questions/797 ... duplicates