From cdcd2ee3c9245d1a5b41cbfc5fe2c9fbf0c52cf7 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Mon, 20 May 2024 02:32:30 +0200 Subject: [PATCH] Add some docs --- py-polars/src/to_numpy.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/py-polars/src/to_numpy.rs b/py-polars/src/to_numpy.rs index ab098b8ee7dd..2f506f63af6b 100644 --- a/py-polars/src/to_numpy.rs +++ b/py-polars/src/to_numpy.rs @@ -253,6 +253,11 @@ pub(crate) fn reshape_numpy_array( #[pymethods] #[allow(clippy::wrong_self_convention)] impl PyDataFrame { + /// Create a view of the data as a NumPy ndarray. + /// + /// WARNING: The resulting view will show the underlying value for nulls, + /// which may be any value. The caller is responsible for handling nulls + /// appropriately. pub fn to_numpy_view(&self, py: Python) -> Option { if self.df.is_empty() { return None; @@ -320,6 +325,7 @@ impl PyDataFrame { }) } + /// Convert this DataFrame to a NumPy ndarray. pub fn to_numpy(&self, py: Python, order: Wrap) -> Option { let st = dtypes_to_supertype(self.df.iter().map(|s| s.dtype())).ok()?;