Skip to content

Commit

Permalink
docs: Specify strictness in cast (#20067)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Nov 29, 2024
1 parent 09f2a31 commit 3985573
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/polars-plan/src/dsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ impl Expr {

/// Cast expression to another data type.
/// Throws an error if conversion had overflows.
/// Returns an Error if cast is invalid on rows after predicates are pushed down.
pub fn strict_cast(self, dtype: DataType) -> Self {
Expr::Cast {
expr: Arc::new(self),
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7727,8 +7727,8 @@ def cast(
Mapping of column names (or selector) to dtypes, or a single dtype
to which all columns will be cast.
strict
Throw an error if a cast could not be done (for instance, due to an
overflow).
Raise if cast is invalid on rows after predicates are pusded down.
If `False`, invalid casts will produce null values.
Examples
--------
Expand Down
3 changes: 2 additions & 1 deletion py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,8 @@ def cast(
dtype
DataType to cast to.
strict
If True invalid casts generate exceptions instead of `null`\s.
Raise if cast is invalid on rows after predicates are pushed down.
If `False`, invalid casts will produce null values.
wrap_numerical
If True numeric casts wrap overflowing values instead of
marking the cast as invalid.
Expand Down

0 comments on commit 3985573

Please sign in to comment.