- pandas:
Код: Выделить всё
uniques = df["a"].value_counts()
df.loc[~df["a"].isin(uniques[uniques > 50].index), "a"] = "other"
- Моя попытка с полярами:
Код: Выделить всё
df = df.with_columns(pl.when(pl.col("a").unique_counts() < 50).then("other").otherwise(pl.col("a")).alias("a"))
Я нигде не нашел ничего об этом конкретном варианте использования.
Спасибо.>
Подробнее здесь: https://stackoverflow.com/questions/760 ... ferent-spe
Мобильная версия