Skip to content

Commit

Permalink
docs(python): Improve formatting and consistency of various docstrings (
Browse files Browse the repository at this point in the history
#18237)

Co-authored-by: Henry Harbeck <henry.harbeck@canstar.com.au>
  • Loading branch information
henryharbeck and Henry Harbeck authored Aug 19, 2024
1 parent 6486cf1 commit c117cbe
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion crates/polars-python/src/series/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl PySeries {
if let Some(output_type) = output_type {
return Ok(Series::full_null(series.name(), series.len(), &output_type.0).into());
}
let msg = "The output type of the 'apply' function cannot be determined.\n\
let msg = "The output type of the 'map_elements' function cannot be determined.\n\
The function was never called because 'skip_nulls=True' and all values are null.\n\
Consider setting 'skip_nulls=False' or setting the 'return_dtype'.";
raise_err!(msg, ComputeError)
Expand Down
14 changes: 7 additions & 7 deletions py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4300,14 +4300,14 @@ def map_batches(
Dtype of the output Series.
If not set, the dtype will be inferred based on the first non-null value
that is returned by the function.
is_elementwise
If set to true this can run in the streaming engine, but may yield
incorrect results in group-by. Ensure you know what you are doing!
agg_list
Aggregate the values of the expression into a list before applying the
function. This parameter only works in a group-by context.
The function will be invoked only once on a list of groups, rather than
once per group.
is_elementwise
If set to true this can run in the streaming engine, but may yield
incorrect results in group-by. Ensure you know what you are doing!
returns_scalar
If the function returns a scalar, by default it will be wrapped in
a list in the output, since the assumption is that the function
Expand Down Expand Up @@ -4745,7 +4745,7 @@ def flatten(self) -> Expr:
"""
Flatten a list or string column.
Alias for :func:`polars.expr.list.ExprListNameSpace.explode`.
Alias for :func:`Expr.list.explode`.
Examples
--------
Expand Down Expand Up @@ -4885,7 +4885,7 @@ def head(self, n: int | Expr = 10) -> Expr:
Examples
--------
>>> df = pl.DataFrame({"foo": [1, 2, 3, 4, 5, 6, 7]})
>>> df.head(3)
>>> df.select(pl.col("foo").head(3))
shape: (3, 1)
┌─────┐
│ foo │
Expand All @@ -4911,7 +4911,7 @@ def tail(self, n: int | Expr = 10) -> Expr:
Examples
--------
>>> df = pl.DataFrame({"foo": [1, 2, 3, 4, 5, 6, 7]})
>>> df.tail(3)
>>> df.select(pl.col("foo").tail(3))
shape: (3, 1)
┌─────┐
│ foo │
Expand Down Expand Up @@ -4942,7 +4942,7 @@ def limit(self, n: int | Expr = 10) -> Expr:
Examples
--------
>>> df = pl.DataFrame({"foo": [1, 2, 3, 4, 5, 6, 7]})
>>> df.limit(3)
>>> df.select(pl.col("foo").limit(3))
shape: (3, 1)
┌─────┐
│ foo │
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/expr/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ def explode(self) -> Expr:
See Also
--------
ExprNameSpace.reshape: Reshape this Expr to a flat Series or a Series of Lists.
Expr.reshape: Reshape this Expr to a flat Series or a Series of Lists.
Examples
--------
Expand Down
8 changes: 4 additions & 4 deletions py-polars/polars/expr/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ def contains(
self, pattern: str | Expr, *, literal: bool = False, strict: bool = True
) -> Expr:
"""
Check if string contains a substring that matches a pattern.
Check if the string contains a substring that matches a pattern.
Parameters
----------
Expand Down Expand Up @@ -1034,7 +1034,7 @@ def find(
See Also
--------
contains : Check if string contains a substring that matches a regex.
contains : Check if the string contains a substring that matches a pattern.
Examples
--------
Expand Down Expand Up @@ -1093,7 +1093,7 @@ def ends_with(self, suffix: str | Expr) -> Expr:
See Also
--------
contains : Check if string contains a substring that matches a regex.
contains : Check if the string contains a substring that matches a pattern.
starts_with : Check if string values start with a substring.
Examples
Expand Down Expand Up @@ -1156,7 +1156,7 @@ def starts_with(self, prefix: str | Expr) -> Expr:
See Also
--------
contains : Check if string contains a substring that matches a regex.
contains : Check if the string contains a substring that matches a pattern.
ends_with : Check if string values end with a substring.
Examples
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2494,7 +2494,7 @@ def starts_with(*prefix: str) -> SelectorType:

def string(*, include_categorical: bool = False) -> SelectorType:
"""
Select all String (and, optionally, Categorical) string columns .
Select all String (and, optionally, Categorical) string columns.
See Also
--------
Expand Down
8 changes: 4 additions & 4 deletions py-polars/polars/series/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def contains(
self, pattern: str | Expr, *, literal: bool = False, strict: bool = True
) -> Series:
"""
Check if strings in Series contain a substring that matches a regex.
Check if the string contains a substring that matches a pattern.
Parameters
----------
Expand Down Expand Up @@ -480,7 +480,7 @@ def find(
See Also
--------
contains : Check if string contains a substring that matches a regex.
contains : Check if the string contains a substring that matches a pattern.
Examples
--------
Expand Down Expand Up @@ -535,7 +535,7 @@ def ends_with(self, suffix: str | Expr) -> Series:
See Also
--------
contains : Check if string contains a substring that matches a regex.
contains : Check if the string contains a substring that matches a pattern.
starts_with : Check if string values start with a substring.
Examples
Expand All @@ -562,7 +562,7 @@ def starts_with(self, prefix: str | Expr) -> Series:
See Also
--------
contains : Check if string contains a substring that matches a regex.
contains : Check if the string contains a substring that matches a pattern.
ends_with : Check if string values end with a substring.
Examples
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def test_skip_nulls_err() -> None:

with pytest.raises(
ComputeError,
match=r"The output type of the 'apply' function cannot be determined",
match=r"The output type of the 'map_elements' function cannot be determined",
):
df.with_columns(pl.col("foo").map_elements(lambda x: x, skip_nulls=True))

Expand Down

0 comments on commit c117cbe

Please sign in to comment.