Struct GroupBy

Source
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>

Source

pub fn count(&self) -> AxionResult<DataFrame>

计算每个组的行数。

§返回值

返回包含分组键和对应计数的新 DataFrame

§示例
let grouped = df.groupby(&["类别"])?;
let count_df = grouped.count()?;
Source

pub fn sum(&self) -> AxionResult<DataFrame>

计算每个组中数值列的和。

非数值列(不是分组键的列)将被忽略。 组内的 null 值在求和时被忽略(空组或全 null 组的和为 0)。

§返回值

返回包含分组键和对应求和结果的新 DataFrame

Source

pub fn mean(&self) -> AxionResult<DataFrame>

计算每个组中数值列的平均值。

非数值列(不是分组键的列)将被忽略。 组内的 null 值在计算时被忽略(空组或全 null 组的平均值为 null)。

§返回值

返回包含分组键和对应平均值的新 DataFrame,平均值列的类型为 f64

Source

pub fn min(&self) -> AxionResult<DataFrame>

计算每个组中可比较列的最小值。

非可比较列(如 List)和分组键列将被忽略。 计算中会忽略 null 值。 结果列的类型将与原始列相同。

§返回值

返回包含分组键和对应最小值的新 DataFrame

Source

pub fn max(&self) -> AxionResult<DataFrame>

计算每个组中可比较列的最大值。

非可比较列(如 List)和分组键列将被忽略。 计算中会忽略 null 值。 结果列的类型将与原始列相同。

§返回值

返回包含分组键和对应最大值的新 DataFrame

Trait Implementations§

Source§

impl<'a> Debug for GroupBy<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.