Skip to content

Commit

Permalink
Update Rust bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Oct 21, 2023
1 parent e65bbb7 commit 9da2409
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 0 additions & 4 deletions py-polars/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,10 +1229,6 @@ impl PyDataFrame {
Ok(unsafe { std::mem::transmute::<Vec<DataFrame>, Vec<PyDataFrame>>(out) })
}

pub fn shift(&self, periods: i64) -> Self {
self.df.shift(periods).into()
}

pub fn lazy(&self) -> PyLazyFrame {
self.df.clone().lazy().into()
}
Expand Down
8 changes: 4 additions & 4 deletions py-polars/src/expr/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
8 changes: 4 additions & 4 deletions py-polars/src/lazyframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9da2409

Please sign in to comment.