Например, предположим, что у меня есть следующий набор данных:
Код: Выделить всё
import polars as pl
df = pl.DataFrame({
'data': [1,1,1,1,1,2,2],
'group': [1,1,1,2,2,1,1],
'id': [1,2,3,4,5,1,2],
'x': [1,1,2,1,2,1,1]
})
Я попробовал следующее, но получил сообщение об ошибке:
Код: Выделить всё
df.filter(pl.col('x').unique_counts().over('data', 'group') >= 2)
Код: Выделить всё
# ShapeError: the length of the window expression did not match that of the group
Подробнее здесь: https://stackoverflow.com/questions/783 ... hin-groups