Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-python/src/dataframe/mod.rs
7889 views
1
#[cfg(feature = "pymethods")]
2
mod construction;
3
#[cfg(feature = "pymethods")]
4
mod export;
5
#[cfg(feature = "pymethods")]
6
mod general;
7
#[cfg(feature = "pymethods")]
8
mod io;
9
#[cfg(feature = "pymethods")]
10
mod map;
11
#[cfg(feature = "pymethods")]
12
mod serde;
13
14
use parking_lot::RwLock;
15
use polars::prelude::DataFrame;
16
use pyo3::pyclass;
17
18
#[pyclass(frozen)]
19
#[repr(transparent)]
20
pub struct PyDataFrame {
21
pub df: RwLock<DataFrame>,
22
}
23
24
impl Clone for PyDataFrame {
25
fn clone(&self) -> Self {
26
PyDataFrame {
27
df: RwLock::new(self.df.read().clone()),
28
}
29
}
30
}
31
32
impl From<DataFrame> for PyDataFrame {
33
fn from(df: DataFrame) -> Self {
34
Self::new(df)
35
}
36
}
37
38
impl From<PyDataFrame> for DataFrame {
39
fn from(pdf: PyDataFrame) -> Self {
40
pdf.df.into_inner()
41
}
42
}
43
44
impl PyDataFrame {
45
pub(crate) fn new(df: DataFrame) -> Self {
46
PyDataFrame {
47
df: RwLock::new(df),
48
}
49
}
50
}
51
52