Skip to content

Commit

Permalink
docs[python] more expr docstrings (#4992)
Browse files Browse the repository at this point in the history
  • Loading branch information
braaannigan committed Sep 28, 2022
1 parent 0ea2230 commit cfee8f4
Show file tree
Hide file tree
Showing 4 changed files with 1,310 additions and 21 deletions.
33 changes: 33 additions & 0 deletions py-polars/polars/internals/expr/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,39 @@ def second(self, fractional: bool = False) -> pli.Expr:
│ 5.765431 │
└──────────┘
>>> from datetime import timedelta, datetime
>>> start = datetime(2001, 1, 1)
>>> stop = datetime(2001, 1, 1, 0, 0, 4)
>>> df = pl.DataFrame(
... {"date": pl.date_range(start, stop, timedelta(seconds=2))}
... )
>>> df
shape: (3, 1)
┌─────────────────────┐
│ date │
│ --- │
│ datetime[μs] │
╞═════════════════════╡
│ 2001-01-01 00:00:00 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 2001-01-01 00:00:02 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 2001-01-01 00:00:04 │
└─────────────────────┘
>>> df.select(pl.col("date").dt.second())
shape: (3, 1)
┌──────┐
│ date │
│ --- │
│ u32 │
╞══════╡
│ 0 │
├╌╌╌╌╌╌┤
│ 2 │
├╌╌╌╌╌╌┤
│ 4 │
└──────┘
"""
sec = pli.wrap_expr(self._pyexpr.second())
return (
Expand Down
14 changes: 5 additions & 9 deletions py-polars/polars/internals/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,7 @@ def fill_null(
"""
Fill null values using the specified value or strategy.
To interpolate over null values see interpolate
To interpolate over null values see interpolate.
Parameters
----------
Expand Down Expand Up @@ -3630,7 +3630,7 @@ def interpolate(self) -> Expr:
"""
Fill nulls with linear interpolation over missing values.
Can also be used to regrid data to a new grid - see examples below
Can also be used to regrid data to a new grid - see examples below.
Examples
--------
Expand Down Expand Up @@ -5939,18 +5939,14 @@ def set_sorted(self, reverse: bool = False) -> Expr:
Examples
--------
>>> df = pl.DataFrame({"values": [1, 3, 2]})
>>> df.select(pl.col("values").sort().set_sorted())
shape: (3, 1)
>>> df = pl.DataFrame({"values": [1, 2, 3]})
>>> df.select(pl.col("values").set_sorted().max())
shape: (1, 1)
┌────────┐
│ values │
│ --- │
│ i64 │
╞════════╡
│ 1 │
├╌╌╌╌╌╌╌╌┤
│ 2 │
├╌╌╌╌╌╌╌╌┤
│ 3 │
└────────┘
Expand Down

0 comments on commit cfee8f4

Please sign in to comment.