Skip to content

Commit

Permalink
Remove duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Aug 29, 2023
1 parent 4636523 commit 0ebe95e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions py-polars/polars/functions/whenthen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ def when(condition: IntoExpr) -> pl.When:
Expression similar to an `if-else` statement in Python. Always initiated by a
`pl.when(<condition>).then(<value if condition>)`. Optionally followed by chaining
one or more `.when(<condition>).then(<value>)` statements. Chained `when, thens`
should be read as Python `if, elif, ... elif` blocks, not as `if, if, ... if`, i.e.
the first condition that evaluates to True will be picked.
one or more `.when(<condition>).then(<value>)` statements.
Chained `when, thens` should be read as Python `if, elif, ... elif` blocks, not as
`if, if, ... if`, i.e. the first condition that evaluates to True will be picked.
If none of the conditions are `True`, an optional `.otherwise(<value if all
statements are false>)` can be appended at the end. If not appended, and none
Expand Down Expand Up @@ -85,9 +86,7 @@ def when(condition: IntoExpr) -> pl.When:
│ 4 ┆ 0 ┆ 1 │
└─────┴─────┴─────┘
Chained `when, thens` should be read as `if, elif, ... elif`, not
as `if, if, ... if`, i.e. the first condition that evaluates to True will
be picked. Note how in the example above for the second row in the dataframe,
Note how in the example above for the second row in the dataframe,
where `foo=3` and `bar=4`, the first `when` evaluates to `True`, and therefore
the second `when`, which is also `True`, is not evaluated.
Expand Down

0 comments on commit 0ebe95e

Please sign in to comment.