diff --git a/crates/polars-ops/src/chunked_array/strings/namespace.rs b/crates/polars-ops/src/chunked_array/strings/namespace.rs index 9948b0f006b57..0d4731f4afb28 100644 --- a/crates/polars-ops/src/chunked_array/strings/namespace.rs +++ b/crates/polars-ops/src/chunked_array/strings/namespace.rs @@ -598,7 +598,7 @@ pub trait StringNameSpaceImpl: AsString { /// the end of the string. fn str_head(&self, n: &Series) -> PolarsResult { let ca = self.as_string(); - let n = n.cast(&DataType::Int64)?; + let n = n.strict_cast(&DataType::Int64)?; Ok(substring::head(ca, n.i64()?)) } @@ -609,7 +609,7 @@ pub trait StringNameSpaceImpl: AsString { /// negative, in which case the slice begins `n` characters from the end of the string. fn str_tail(&self, n: &Series) -> PolarsResult { let ca = self.as_string(); - let n = n.cast(&DataType::Int64)?; + let n = n.strict_cast(&DataType::Int64)?; Ok(substring::tail(ca, n.i64()?)) }