{"record":{"id":"bc97c6b1e7eeb4d4","repo":"pola-rs/polars","slug":"series-length-mismatch-expected-n-r-found-m-r","errorCode":null,"errorMessage":"Series length mismatch: expected {n!r}, found {m!r}","messagePattern":"Series length mismatch: expected (.+?), found (.+?)","errorType":"exception","errorClass":"ShapeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/series/series.py","lineNumber":5724,"sourceCode":"\n        Examples\n        --------\n        >>> s = pl.Series(\"a\", [1, 2, 3])\n        >>> s2 = pl.Series(\"b\", [4.0, 5.0, 6.0])\n        >>> s.dot(s2)\n        32.0\n\n        Parameters\n        ----------\n        other\n            Series (or array) to compute dot product with.\n        \"\"\"\n        if not isinstance(other, Series):\n            other = Series(other)\n        if len(self) != len(other):\n            n, m = len(self), len(other)\n            msg = f\"Series length mismatch: expected {n!r}, found {m!r}\"\n            raise ShapeError(msg)\n        return self._s.dot(other._s)\n\n    def mode(self, *, maintain_order: bool = False) -> Series:\n        \"\"\"\n        Compute the most occurring value(s).\n\n        Can return multiple Values.\n\n        Parameters\n        ----------\n        maintain_order\n            Maintain order of data. This requires more work.\n\n        Examples\n        --------\n        >>> s = pl.Series(\"a\", [1, 2, 2, 3])\n        >>> s.mode()\n        shape: (1,)","sourceCodeStart":5706,"sourceCodeEnd":5742,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/series/series.py#L5706-L5742","documentation":"dot() length check: the dot product requires both Series to have the same number of elements; the guard raises ShapeError with expected vs found lengths when they differ. Triggered by mismatched vectors or arrays of different length.","triggerScenarios":"Thrown at py-polars/src/polars/series/series.py:5880 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the lengths match: pass values with the same length as the expected Series length, or adjust the expected length."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}