pub struct GroupedDataFrame {
source: DataFrame,
groups: Vec<(GroupKey, Vec<usize>)>,
}Expand description
A DataFrame partitioned by the values of one key column.
Produced by DataFrame::group_by. Holds the source frame plus one
(key, row-indices) pair per group; nothing is copied until you ask for
frames or extract.
§GC rooting
The source frame is preserved on R’s precious list
(R_PreserveObject) for this struct’s lifetime and released on drop —
order-independent, unlike the PROTECT stack, so the struct can be held
across arbitrary allocations (e.g. a locally built frame from
DataFrame::builder, which is unprotected once build() returns).
Without this, the per-group allocations in frames /
extract could collect the source mid-iteration.
Main-thread-only (holds a SEXP; !Send).
Fields§
§source: DataFrame§groups: Vec<(GroupKey, Vec<usize>)>Implementations§
Source§impl GroupedDataFrame
impl GroupedDataFrame
Sourcepub fn iter(&self) -> impl Iterator<Item = (&GroupKey, &[usize])>
pub fn iter(&self) -> impl Iterator<Item = (&GroupKey, &[usize])>
Iterate (key, row-indices) pairs in group order. Indices are 0-based
rows of source.
Sourcepub fn frames(&self) -> impl Iterator<Item = (&GroupKey, DataFrame)>
pub fn frames(&self) -> impl Iterator<Item = (&GroupKey, DataFrame)>
Iterate (key, sub-frame) pairs, materialising each group as its own
DataFrame via DataFrame::select_rows.
Main thread only. Each yielded frame is unprotected — root it
before the next iteration allocates (e.g. push it straight into a
NamedDataFrameListBuilder,
which protects on push) or convert it to Rust data immediately.
Sourcepub fn extract<T>(&self) -> Result<Vec<(GroupKey, Vec<T>)>, DataFrameError>where
Vec<T>: FromDataFrame,
pub fn extract<T>(&self) -> Result<Vec<(GroupKey, Vec<T>)>, DataFrameError>where
Vec<T>: FromDataFrame,
Extract typed rows once, then partition them by group.
One Vec::<T>::from_dataframe pass over the whole frame, then a
move-partition by the stored indices — no per-group R subsetting and no
Clone bound. The result is plain Rust data (rayon-safe afterwards).
Trait Implementations§
Source§impl Drop for GroupedDataFrame
impl Drop for GroupedDataFrame
Auto Trait Implementations§
impl Freeze for GroupedDataFrame
impl RefUnwindSafe for GroupedDataFrame
impl Send for GroupedDataFrame
impl Sync for GroupedDataFrame
impl Unpin for GroupedDataFrame
impl UnsafeUnpin for GroupedDataFrame
impl UnwindSafe for GroupedDataFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes