pub struct GroupBy<'a> { /* private fields */ }Expand description
表示分组操作的中间状态。
持有对原始 DataFrame 的引用和计算出的分组索引。 可以在此基础上执行各种聚合操作,如计数、求和、平均值等。
§示例
let grouped = df.groupby(&["类别"])?;
let count_result = grouped.count()?;
let sum_result = grouped.sum()?;
let mean_result = grouped.mean()?;Implementations§
Source§impl<'a> GroupBy<'a>
impl<'a> GroupBy<'a>
Sourcepub fn count(&self) -> AxionResult<DataFrame>
pub fn count(&self) -> AxionResult<DataFrame>
Sourcepub fn sum(&self) -> AxionResult<DataFrame>
pub fn sum(&self) -> AxionResult<DataFrame>
计算每个组中数值列的和。
非数值列(不是分组键的列)将被忽略。 组内的 null 值在求和时被忽略(空组或全 null 组的和为 0)。
§返回值
返回包含分组键和对应求和结果的新 DataFrame
Sourcepub fn mean(&self) -> AxionResult<DataFrame>
pub fn mean(&self) -> AxionResult<DataFrame>
计算每个组中数值列的平均值。
非数值列(不是分组键的列)将被忽略。 组内的 null 值在计算时被忽略(空组或全 null 组的平均值为 null)。
§返回值
返回包含分组键和对应平均值的新 DataFrame,平均值列的类型为 f64
Sourcepub fn min(&self) -> AxionResult<DataFrame>
pub fn min(&self) -> AxionResult<DataFrame>
计算每个组中可比较列的最小值。
非可比较列(如 List)和分组键列将被忽略。 计算中会忽略 null 值。 结果列的类型将与原始列相同。
§返回值
返回包含分组键和对应最小值的新 DataFrame
Sourcepub fn max(&self) -> AxionResult<DataFrame>
pub fn max(&self) -> AxionResult<DataFrame>
计算每个组中可比较列的最大值。
非可比较列(如 List)和分组键列将被忽略。 计算中会忽略 null 值。 结果列的类型将与原始列相同。
§返回值
返回包含分组键和对应最大值的新 DataFrame
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for GroupBy<'a>
impl<'a> !RefUnwindSafe for GroupBy<'a>
impl<'a> Send for GroupBy<'a>
impl<'a> Sync for GroupBy<'a>
impl<'a> Unpin for GroupBy<'a>
impl<'a> !UnwindSafe for GroupBy<'a>
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more