From 9da2409671a6656be388586953f63780e045a0f6 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 21 Oct 2023 17:34:11 +0200 Subject: [PATCH] Update Rust bindings --- py-polars/polars/dataframe/frame.py | 4 ++-- py-polars/src/dataframe.rs | 4 ---- py-polars/src/expr/general.rs | 8 ++++---- py-polars/src/lazyframe.rs | 8 ++++---- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index 8a4e9cc429f0..6d50e3393fa7 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -7457,7 +7457,7 @@ def partition_by( return partitions @deprecate_renamed_parameter("periods", "n", version="0.19.11") - def shift(self, n: int = 1) -> Self: + def shift(self, n: int = 1) -> DataFrame: """ Shift values by the given number of places. @@ -7503,7 +7503,7 @@ def shift(self, n: int = 1) -> Self: └──────┴──────┴──────┘ """ - return self._from_pydf(self._df.shift(n)) + return self.lazy().shift(n=n).collect(_eager=True) @deprecate_renamed_parameter("periods", "n", version="0.19.11") def shift_and_fill( diff --git a/py-polars/src/dataframe.rs b/py-polars/src/dataframe.rs index 98e8bae5ce89..235ad3e75953 100644 --- a/py-polars/src/dataframe.rs +++ b/py-polars/src/dataframe.rs @@ -1229,10 +1229,6 @@ impl PyDataFrame { Ok(unsafe { std::mem::transmute::, Vec>(out) }) } - pub fn shift(&self, periods: i64) -> Self { - self.df.shift(periods).into() - } - pub fn lazy(&self) -> PyLazyFrame { self.df.clone().lazy().into() } diff --git a/py-polars/src/expr/general.rs b/py-polars/src/expr/general.rs index 46137400969c..a32a78d8bb8d 100644 --- a/py-polars/src/expr/general.rs +++ b/py-polars/src/expr/general.rs @@ -335,13 +335,13 @@ impl PyExpr { self.clone().inner.forward_fill(limit).into() } - fn shift(&self, periods: i64) -> Self { - self.clone().inner.shift(periods).into() + fn shift(&self, n: i64) -> Self { + self.clone().inner.shift(n).into() } - fn shift_and_fill(&self, periods: i64, fill_value: Self) -> Self { + fn shift_and_fill(&self, n: i64, fill_value: Self) -> Self { self.clone() .inner - .shift_and_fill(periods, fill_value.inner) + .shift_and_fill(n, fill_value.inner) .into() } diff --git a/py-polars/src/lazyframe.rs b/py-polars/src/lazyframe.rs index 64815d0f551c..fa5bfb18ee12 100644 --- a/py-polars/src/lazyframe.rs +++ b/py-polars/src/lazyframe.rs @@ -834,14 +834,14 @@ impl PyLazyFrame { ldf.reverse().into() } - fn shift(&self, periods: i64) -> Self { + fn shift(&self, n: i64) -> Self { let ldf = self.ldf.clone(); - ldf.shift(periods).into() + ldf.shift(n).into() } - fn shift_and_fill(&self, periods: i64, fill_value: PyExpr) -> Self { + fn shift_and_fill(&self, n: i64, fill_value: PyExpr) -> Self { let ldf = self.ldf.clone(); - ldf.shift_and_fill(periods, fill_value.inner).into() + ldf.shift_and_fill(n, fill_value.inner).into() } fn fill_nan(&self, fill_value: PyExpr) -> Self {