Skip to content

Commit

Permalink
Update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Oct 23, 2023
1 parent b731b06 commit b90a733
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 69 deletions.
24 changes: 3 additions & 21 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10151,34 +10151,16 @@ def shift_and_fill(
"""
Shift values by the given number of places and fill the resulting null values.
.. deprecated:: 0.19.12
Use :func:`shift` instead.
Parameters
----------
fill_value
fill None values with this value.
n
Number of places to shift (may be negative).
Examples
--------
>>> df = pl.DataFrame(
... {
... "foo": [1, 2, 3],
... "bar": [6, 7, 8],
... "ham": ["a", "b", "c"],
... }
... )
>>> df.shift_and_fill(n=1, fill_value=0)
shape: (3, 3)
┌─────┬─────┬─────┐
│ foo ┆ bar ┆ ham │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ str │
╞═════╪═════╪═════╡
│ 0 ┆ 0 ┆ 0 │
│ 1 ┆ 6 ┆ a │
│ 2 ┆ 7 ┆ b │
└─────┴─────┴─────┘
"""
return self.shift(n, fill_value=fill_value)

Expand Down
21 changes: 4 additions & 17 deletions py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2417,7 +2417,7 @@ def shift(self, n: int = 1, *, fill_value: IntoExpr | None = None) -> Self:
By default, values are shifted down one row.
>>> df = pl.DataFrame({"a": [1, 2, 3, 4]})
>>> df.with_columns(shift=pl.col("foo").shift())
>>> df.with_columns(shift=pl.col("a").shift())
shape: (4, 2)
┌─────┬───────┐
│ a ┆ shift │
Expand Down Expand Up @@ -9571,29 +9571,16 @@ def shift_and_fill(
"""
Shift values by the given number of places and fill the resulting null values.
.. deprecated:: 0.19.12
Use :func:`shift` instead.
Parameters
----------
fill_value
Fill None values with the result of this expression.
n
Number of places to shift (may be negative).
Examples
--------
>>> df = pl.DataFrame({"foo": [1, 2, 3, 4]})
>>> df.with_columns(foo_shifted=pl.col("foo").shift_and_fill("a", n=1))
shape: (4, 2)
┌─────┬─────────────┐
│ foo ┆ foo_shifted │
│ --- ┆ --- │
│ i64 ┆ str │
╞═════╪═════════════╡
│ 1 ┆ a │
│ 2 ┆ 1 │
│ 3 ┆ 2 │
│ 4 ┆ 3 │
└─────┴─────────────┘
"""
return self.shift(n, fill_value=fill_value)

Expand Down
34 changes: 3 additions & 31 deletions py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6173,43 +6173,15 @@ def shift_and_fill(
"""
Shift values by the given number of places and fill the resulting null values.
.. deprecated:: 0.19.12
Use :func:`shift` instead.
Parameters
----------
fill_value
fill None values with the result of this expression.
n
Number of places to shift (may be negative).
Examples
--------
>>> lf = pl.LazyFrame(
... {
... "a": [1, 3, 5],
... "b": [2, 4, 6],
... }
... )
>>> lf.shift_and_fill(fill_value=0, n=1).collect()
shape: (3, 2)
┌─────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 0 ┆ 0 │
│ 1 ┆ 2 │
│ 3 ┆ 4 │
└─────┴─────┘
>>> lf.shift_and_fill(fill_value=0, n=-1).collect()
shape: (3, 2)
┌─────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 3 ┆ 4 │
│ 5 ┆ 6 │
│ 0 ┆ 0 │
└─────┴─────┘
"""
return self.shift(n, fill_value=fill_value)
3 changes: 3 additions & 0 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -6864,6 +6864,9 @@ def shift_and_fill(
"""
Shift values by the given number of places and fill the resulting null values.
.. deprecated:: 0.19.12
Use :func:`shift` instead.
Parameters
----------
fill_value
Expand Down

0 comments on commit b90a733

Please sign in to comment.