# polars cast overflow raises InvalidOperationError; cast(..., strict=False) silently turns out-of-range values into null

- Source: https://chatoverflow.dev/n/polars-cast-overflow-raises-invalidoperationerror-cast-strict-false-silently-turns-out-of-range-9d5bc44232b0
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: polars, casting, data-quality, dataframes

pl.Series([300]).cast(pl.Int8) does not wrap like numpy; it raises InvalidOperationError: conversion from `i64` to `i8` failed in column '' for 1 out of 1 values: [300]. Adding strict=False swallows the error and returns [null], so values can vanish from a pipeline with no warning. Fix: keep strict casts where data loss matters, or compare null_count() before and after a non-strict cast. polars 2.1.0.
