{"record":{"id":"a43e2287167d2215","repo":"pola-rs/polars","slug":"cannot-compare-two-series-of-different-lengths","errorCode":null,"errorMessage":"Cannot compare two series of different lengths.","messagePattern":"Cannot compare two series of different lengths\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/chunked_array/comparison/mod.rs","lineNumber":243,"sourceCode":"        BooleanChunked::full_null(self.name().clone(), get_broadcast_length(self, rhs))\n    }\n\n    fn lt(&self, rhs: &NullChunked) -> Self::Item {\n        BooleanChunked::full_null(self.name().clone(), get_broadcast_length(self, rhs))\n    }\n\n    fn lt_eq(&self, rhs: &NullChunked) -> Self::Item {\n        BooleanChunked::full_null(self.name().clone(), get_broadcast_length(self, rhs))\n    }\n}\n\n#[inline]\nfn get_broadcast_length(lhs: &NullChunked, rhs: &NullChunked) -> usize {\n    match (lhs.len(), rhs.len()) {\n        (1, len_r) => len_r,\n        (len_l, 1) => len_l,\n        (len_l, len_r) if len_l == len_r => len_l,\n        _ => panic!(\"Cannot compare two series of different lengths.\"),\n    }\n}\n\nimpl ChunkCompareEq<&BooleanChunked> for BooleanChunked {\n    type Item = BooleanChunked;\n\n    fn equal(&self, rhs: &BooleanChunked) -> BooleanChunked {\n        // Broadcast.\n        match (self.len(), rhs.len()) {\n            (_, 1) => {\n                if let Some(value) = rhs.get(0) {\n                    arity::unary_mut_values(self, |arr| arr.tot_eq_kernel_broadcast(&value).into())\n                } else {\n                    BooleanChunked::full_null(PlSmallStr::EMPTY, self.len())\n                }\n            },\n            (1, _) => {\n                if let Some(value) = self.get(0) {","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-core/src/chunked_array/comparison/mod.rs#L225-L261","documentation":"Panic in get_broadcast_length when comparing two NullChunked (or series) of incompatible lengths: neither side has length 1 (broadcastable) and the lengths differ, so element-wise comparison is undefined. Align the lengths or broadcast one side.","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"Cannot compare two series of different lengths.\". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.","commonSituations":"Encountered when input data or configuration does not meet the preconditions of the throwing code path (\"Cannot compare two series of different lengths.\"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.","solutions":["Compare only series of equal length; check `.len()` on both sides before the comparison.","Reindex, join, or zip the two series so they align row-by-row before comparing.","If one side is meant as a scalar, wrap it with `lit()` or broadcast it explicitly."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}