pub trait IntoDataFrame: Sized {
// Required method
fn into_dataframe(self) -> Result<BuiltDataFrame, DataFrameError>;
}Expand description
Rust data → R data.frame. The data-frame analogue of IntoR.
Implemented for Vec<Row> when Row derives DataFrameRow (struct or enum), and by the
serde column path. Call it on your data: rows.into_dataframe()?.
Borrowed rows convert too: rows.as_slice().into_dataframe()? or
(&rows).into_dataframe()? (&[Row] / &Vec<Row>) build the same frame without
consuming the rows, which is what a &self method holding a Vec<Row> needs.
String and Option<String> columns are then written from &str, and every other
field value is cloned once into its column, so those field types need Clone.
§Parallel fast path
into_dataframe_par (present only with
feature = "rayon") produces the same BuiltDataFrame as
into_dataframe. It defaults to the sequential path, so
every implementor gets a correct _par for free; #[derive(DataFrameRow)] row types
override it with a genuinely parallel column fill (the #777 flattened (column,row-range)
work-list). The verb is stable across feature sets — dropping _par degrades cleanly to
the sequential call.
Required Methods§
Sourcefn into_dataframe(self) -> Result<BuiltDataFrame, DataFrameError>
fn into_dataframe(self) -> Result<BuiltDataFrame, DataFrameError>
Convert this value into an owned, GC-rooted BuiltDataFrame.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: DataFrameRowBorrow> IntoDataFrame for &Vec<T>
&Vec<Row> converts exactly as the borrowed slice &[Row] does.
impl<T: DataFrameRowBorrow> IntoDataFrame for &Vec<T>
&Vec<Row> converts exactly as the borrowed slice &[Row] does.
This impl is what makes (&self.rows).into_dataframe() work: without it,
method lookup would dereference to the owned Vec<Row> impl. Where this
impl does not apply (a field type that is not Clone), lookup still falls
through to that owned impl, so the error is “cannot move out of a shared
reference” (E0507). self.rows.as_slice().into_dataframe() or
IntoDataFrame::into_dataframe(&self.rows) names the field type instead.
fn into_dataframe(self) -> Result<BuiltDataFrame, DataFrameError>
Source§impl<T: DataFrameRowBorrow> IntoDataFrame for &[T]
Borrowed rows → R data.frame, for a #[derive(DataFrameRow)] row type.
impl<T: DataFrameRowBorrow> IntoDataFrame for &[T]
Borrowed rows → R data.frame, for a #[derive(DataFrameRow)] row type.
Builds the same frame as the owned rows.to_vec().into_dataframe() without
the intermediate Vec<Row>: String and Option<String> columns are
written straight from &str, and every other value is cloned once into its
column (so those field types need Clone; the row type does not).
From a &self method, borrow the rows explicitly:
self.rows.as_slice().into_dataframe() or (&self.rows).into_dataframe().
A bare self.rows.into_dataframe() resolves to the owned Vec<Row> impl
and cannot move out of &self.
into_dataframe_par (feature = "rayon") on borrowed rows is the same
sequential fill.