I have a data frame contains a column with some values. Let be 2 a window length, I need a new column which is 1 if all elements in a rolling window are positive, 0 otherwise.
Namely:
┌─────┬─────────────┐
│ col ┆ is_positive │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════════════╡
│ 1 ┆ null │
├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ -1 ┆ 0 │
├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 1 ┆ 0 │
├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ -1 ┆ 0 │
├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 1 ┆ 0 │
├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 1 ┆ 1 │
├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ -1 ┆ 0 │
├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 1 ┆ 0 │
└─────┴─────────────┘
Any advice?
Thanks