Код: Выделить всё
import polars as pl
df = pl.from_repr("""
┌───────────┬─────┬─────┐
│ group_col ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ str ┆ i64 ┆ i64 │
╞═══════════╪═════╪═════╡
│ g1 ┆ 1 ┆ 4 │
│ g1 ┆ 2 ┆ 5 │
│ g2 ┆ 3 ┆ 6 │
└───────────┴─────┴─────┘
""")
Код: Выделить всё
df.group_by("group_col").agg(
pl.col("c").filter((pl.col("b") >= 1) & (pl.col('b').max() == pl.col('b'))).max().alias("gte")
)
Код: Выделить всё
shape: (2, 2)
┌───────────┬─────┐
│ group_col ┆ gte │
│ --- ┆ --- │
│ str ┆ i64 │
╞═══════════╪═════╡
│ g1 ┆ 5 │
│ g2 ┆ 6 │
└───────────┴─────┘
Подробнее здесь: https://stackoverflow.com/questions/773 ... -not-match
Мобильная версия