{"record":{"id":"7105bc27bfabc665","repo":"pola-rs/polars","slug":"cannot-return-a-zero-copy-array","errorCode":null,"errorMessage":"cannot return a zero-copy array","messagePattern":"cannot return a zero-copy array","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/series/series.py","lineNumber":5053,"sourceCode":"    ) -> pd.Series[Any]:\n        \"\"\"\n        Convert this Series to a pandas Series.\n\n        This operation copies data if `use_pyarrow_extension_array` is not enabled.\n\n        Parameters\n        ----------\n        use_pyarrow_extension_array\n            Use a PyArrow-backed extension array instead of a NumPy array for the pandas\n            Series. This allows zero copy operations and preservation of null values.\n            Subsequent operations on the resulting pandas Series may trigger conversion\n            to NumPy if those operations are not supported by PyArrow compute functions.\n        **kwargs\n            Additional keyword arguments to be passed to\n            :meth:`pyarrow.Array.to_pandas`.\n\n        Returns\n        -------\n        :class:`pandas.Series`\n\n        Notes\n        -----\n        This operation requires that both :mod:`pandas` and :mod:`pyarrow` are\n        installed.\n\n        Examples\n        --------\n        >>> s = pl.Series(\"a\", [1, 2, 3])\n        >>> s.to_pandas()\n        0    1\n        1    2\n        2    3\n        Name: a, dtype: int64\n\n        Null values are converted to `NaN`.\n","sourceCodeStart":5035,"sourceCodeEnd":5071,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/series/series.py#L5035-L5071","documentation":"Series.to_pandas documents that data is copied unless use_pyarrow_extension_array=True; when zero-copy is requested but impossible for this series (e.g. a dtype with no matching PyArrow-backed extension array or arrow-backed representation), the code raises this error because it cannot hand out the buffer without copying.","triggerScenarios":"Thrown at py-polars/src/polars/series/series.py:5044 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Allow a copy instead of requiring zero-copy, e.g. call `to_numpy()` without `zero_copy_only=True`, or ensure the Series is contiguous and of a compatible dtype."],"exampleFix":null,"handlingStrategy":"fallback","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"}