Код: Выделить всё
import polars as pl
df = pl.DataFrame({'a':[0.0,0.5,1.0,1.0],'b':[0,0,0,1]})
Код: Выделить всё
shape: (4, 2)
┌─────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ f64 ┆ i64 │
╞═════╪═════╡
│ 0.0 ┆ 0 │
│ 0.5 ┆ 0 │
│ 1.0 ┆ 0 │
│ 1.0 ┆ 1 │
└─────┴─────┘
Код: Выделить всё
df.group_by(
pl.when(pl.col('a')==0)
.then(pl.lit('nothing'))
.when((pl.col('a')>0)&(pl.col('a')
Подробнее здесь: [url]https://stackoverflow.com/questions/76473325/binning-data-into-user-defined-bins-using-group-by-in-polars[/url]
Мобильная версия