0

在惰性 groupby_dynamic 中,我们必须 impl Expr 来编写表达式

但是数据之间可能有很多切片,但是切片 Expr 移动了数据的所有权

trait myfun {
    fn get_res(self) -> Self;
}

impl myfun for Expr {
    fn get_res(self) -> Self {
        let mut a: Expr = lit(0.0);
        let max_day = 5;

        for i in 0..max_day {

            let b = self.slice(i * 48 + 36, 12).mean();
            let c = self.slice(i * 48 + 24, 24).mean();
            a =a+ b/c
                / lit(max_day - i)

                + self.slice(i * 48 + 42, 6).mean()
                    / self.slice(i * 48 + 36, 12).mean()
                    / lit(max_day - i)
                - lit(2.0)
        }
        a


    }
}

 --> qafactorpro-rs\src\main.rs:84:21
    |
78  |     fn get_res(self) -> Self {
    |                ---- move occurs because `self` has type `polars::prelude::Expr`, which does not implement the `Copy` trait
...
84  |             let b = self.slice(i * 48 + 36, 12).mean();
    |                     ^^^^ value used here after move
...
90  |                     / self.slice(i * 48 + 36, 12).mean()
    |                            ---------------------- `self` moved due to this method call, in previous iteration of loop
    |
note: this function takes ownership of the receiver `self`, which moves `self`
   --> C:\Users\yutia\.cargo\git\checkouts\polars-99214b81b66ff0b2\41f63cb\polars\polars-lazy\src\dsl.rs:795:18
    |
795 |     pub fn slice(self, offset: i64, length: usize) -> Self {
    |                  ^^^^


4

0 回答 0