polars_python/dataframe/
mod.rs1#[cfg(feature = "pymethods")]
2mod construction;
3#[cfg(feature = "pymethods")]
4mod export;
5#[cfg(feature = "pymethods")]
6mod general;
7#[cfg(feature = "pymethods")]
8mod io;
9#[cfg(feature = "pymethods")]
10mod serde;
11
12use parking_lot::RwLock;
13use polars::prelude::DataFrame;
14use pyo3::pyclass;
15
16#[pyclass(frozen)]
17#[repr(transparent)]
18pub struct PyDataFrame {
19 pub df: RwLock<DataFrame>,
20}
21
22impl Clone for PyDataFrame {
23 fn clone(&self) -> Self {
24 PyDataFrame {
25 df: RwLock::new(self.df.read().clone()),
26 }
27 }
28}
29
30impl From<DataFrame> for PyDataFrame {
31 fn from(df: DataFrame) -> Self {
32 Self::new(df)
33 }
34}
35
36impl From<PyDataFrame> for DataFrame {
37 fn from(pdf: PyDataFrame) -> Self {
38 pdf.df.into_inner()
39 }
40}
41
42impl PyDataFrame {
43 pub(crate) fn new(df: DataFrame) -> Self {
44 PyDataFrame {
45 df: RwLock::new(df),
46 }
47 }
48}