Skip to main content

DataFrameGroupBy

Struct DataFrameGroupBy 

Source
pub struct DataFrameGroupBy<'a> { /* private fields */ }
Expand description

Deferred GroupBy object for DataFrame.

Created by DataFrame::groupby(). Call aggregation methods to produce results.

Implementations§

Source§

impl DataFrameGroupBy<'_>

Source

pub fn sharing(self, layout: &Arc<DenseGroupLayout>) -> Self

Name the result’s key levels names (one per key; None for an unnamed key) instead of the key column names - for keys a caller grouped by through key columns of its own (fvsao.19). This groupby reading and keeping its single text key’s grouping in layout - the cache the groupby object holds for all its calls and selections, as pandas’ keeps its grouper (br-frankenpandas-e186m).

Source

pub fn with_key_names<N: Into<LabelName>>( self, names: Vec<Option<N>>, ) -> Result<Self, FrameError>

Source

pub fn group_codes(&self) -> Result<(Column, Index), FrameError>

Every row’s group as a code in this groupby’s group order (null where dropna drops the row), and the groups in that order as an index: their flat labels, carrying the row MultiIndex levels when grouping by several keys. A Series grouped by the codes reduces to one value per code, and take of this index at the codes labels that result as pandas labels the groups - how the Python binding runs gb[col] over several keys (br-frankenpandas-rc0923-epic-rust-parity-bugs-4qg5w.9).

Source

pub fn combine_group_stat_frames<F>( &self, stat: F, ) -> Result<DataFrame, FrameError>

stat of every group’s frame (its value columns) stacked under the group keys: pandas’ DataFrameGroupBy.corr / cov shape, the inner level keeping the stat frame’s own index name (pandas’ None; it was ‘index’, c90rr). A caller with the options of its own stat runs it here.

Source

pub fn keys(&self) -> Vec<IndexLabel>

Group labels in group iteration order.

Source

pub fn indices(&self) -> HashMap<IndexLabel, Vec<usize>>

Mapping from group labels to source row positions.

Source

pub fn groups(&self) -> HashMap<IndexLabel, Vec<usize>>

Alias for indices, matching pandas’ groups property shape.

Source

pub fn grouper(&self) -> Vec<String>

Names of the columns used as groupers.

Source

pub fn level(&self) -> Vec<String>

Names of the grouping levels.

Source

pub fn ngroups(&self) -> usize

Number of groups.

Source

pub fn ndim(&self) -> usize

Grouped object dimensionality.

Source

pub fn dtypes(&self) -> Result<Series, FrameError>

DTypes for grouped value columns.

Source

pub fn plot(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped plotting request.

Source

pub fn line(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped line plot request.

Source

pub fn line_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe line plot directly to deterministic SVG string.

Source

pub fn line_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe line plot directly to HTML figure snippet.

Source

pub fn line_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe line plot directly to disk.

Source

pub fn bar(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped bar plot request.

Source

pub fn bar_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe bar plot directly to deterministic SVG string.

Source

pub fn bar_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe bar plot directly to HTML figure snippet.

Source

pub fn bar_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe bar plot directly to disk.

Source

pub fn barh(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped horizontal bar plot request.

Source

pub fn barh_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe horizontal bar plot directly to deterministic SVG string.

Source

pub fn barh_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe horizontal bar plot directly to HTML figure snippet.

Source

pub fn barh_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe horizontal bar plot directly to disk.

Source

pub fn area(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped area plot request.

Source

pub fn area_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe area plot directly to deterministic SVG string.

Source

pub fn area_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe area plot directly to HTML figure snippet.

Source

pub fn area_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe area plot directly to disk.

Source

pub fn scatter(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped scatter plot request.

Source

pub fn scatter_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe scatter plot directly to deterministic SVG string.

Source

pub fn scatter_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe scatter plot directly to HTML figure snippet.

Source

pub fn scatter_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe scatter plot directly to disk.

Source

pub fn scatter_columns(&self, x: &str, y: &str) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped scatter plot request for the specified (x, y) column pair.

Source

pub fn scatter_xy(&self, x: &str, y: &str) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped scatter plot request for the specified (x, y) column pair (alias for DataFrameGroupBy::scatter_columns).

Source

pub fn scatter_columns_to_svg( &self, x: &str, y: &str, ) -> Result<String, FrameError>

Convenience helper: render grouped dataframe (x, y) scatter plot directly to deterministic SVG string.

Source

pub fn scatter_xy_to_svg(&self, x: &str, y: &str) -> Result<String, FrameError>

Convenience helper: render grouped dataframe (x, y) scatter plot directly to deterministic SVG string (alias for DataFrameGroupBy::scatter_columns_to_svg).

Source

pub fn scatter_columns_to_html( &self, x: &str, y: &str, ) -> Result<String, FrameError>

Convenience helper: render grouped dataframe (x, y) scatter plot directly to HTML figure snippet.

Source

pub fn scatter_xy_to_html(&self, x: &str, y: &str) -> Result<String, FrameError>

Convenience helper: render grouped dataframe (x, y) scatter plot directly to HTML figure snippet (alias for DataFrameGroupBy::scatter_columns_to_html).

Source

pub fn scatter_columns_to_file<P: AsRef<Path>>( &self, x: &str, y: &str, path: P, ) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe (x, y) scatter plot directly to disk.

Source

pub fn scatter_xy_to_file<P: AsRef<Path>>( &self, x: &str, y: &str, path: P, ) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe (x, y) scatter plot directly to disk (alias for DataFrameGroupBy::scatter_columns_to_file).

Source

pub fn pie(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped pie plot request.

Source

pub fn pie_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe pie plot directly to deterministic SVG string.

Source

pub fn pie_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe pie plot directly to HTML figure snippet.

Source

pub fn pie_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe pie plot directly to disk.

Source

pub fn kde(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped kernel density estimation plot request.

Source

pub fn kde_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe KDE plot directly to deterministic SVG string.

Source

pub fn kde_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe KDE plot directly to HTML figure snippet.

Source

pub fn kde_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe KDE plot directly to disk.

Source

pub fn density(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped density plot request (alias for DataFrameGroupBy::kde).

Source

pub fn density_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe density plot directly to deterministic SVG string.

Source

pub fn density_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe density plot directly to HTML figure snippet.

Source

pub fn density_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe density plot directly to disk.

Source

pub fn hexbin(&self) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped hexbin plot request.

Source

pub fn hexbin_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe hexbin plot directly to deterministic SVG string.

Source

pub fn hexbin_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe hexbin plot directly to HTML figure snippet.

Source

pub fn hexbin_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe hexbin plot directly to disk.

Source

pub fn hexbin_columns(&self, x: &str, y: &str) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped hexbin plot request for the specified (x, y) column pair.

Source

pub fn hexbin_xy(&self, x: &str, y: &str) -> Result<PlotSpec, FrameError>

Return a backend-neutral pandas-style grouped hexbin plot request for the specified (x, y) column pair (alias for DataFrameGroupBy::hexbin_columns).

Source

pub fn hexbin_columns_to_svg( &self, x: &str, y: &str, ) -> Result<String, FrameError>

Convenience helper: render grouped dataframe (x, y) hexbin plot directly to deterministic SVG string.

Source

pub fn hexbin_xy_to_svg(&self, x: &str, y: &str) -> Result<String, FrameError>

Convenience helper: render grouped dataframe (x, y) hexbin plot directly to deterministic SVG string (alias for DataFrameGroupBy::hexbin_columns_to_svg).

Source

pub fn hexbin_columns_to_html( &self, x: &str, y: &str, ) -> Result<String, FrameError>

Convenience helper: render grouped dataframe (x, y) hexbin plot directly to HTML figure snippet.

Source

pub fn hexbin_xy_to_html(&self, x: &str, y: &str) -> Result<String, FrameError>

Convenience helper: render grouped dataframe (x, y) hexbin plot directly to HTML figure snippet (alias for DataFrameGroupBy::hexbin_columns_to_html).

Source

pub fn hexbin_columns_to_file<P: AsRef<Path>>( &self, x: &str, y: &str, path: P, ) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe (x, y) hexbin plot directly to disk.

Source

pub fn hexbin_xy_to_file<P: AsRef<Path>>( &self, x: &str, y: &str, path: P, ) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe (x, y) hexbin plot directly to disk (alias for DataFrameGroupBy::hexbin_columns_to_file).

Source

pub fn plot_xy( &self, kind: PlotKind, x: &str, y: &str, ) -> Result<PlotSpec, FrameError>

Return a backend-neutral grouped plot request for the specified plot kind and (x, y) column pair.

Source

pub fn plot_with_kind(&self, kind: PlotKind) -> Result<PlotSpec, FrameError>

Return a backend-neutral grouped plot request for the specified plot kind.

Source

pub fn hist(&self) -> Result<HistogramSpec, FrameError>

Return a backend-neutral pandas-style grouped histogram request.

Source

pub fn boxplot(&self) -> Result<BoxPlotSpec, FrameError>

Return a backend-neutral pandas-style grouped boxplot request.

Source

pub fn box_plot(&self) -> Result<BoxPlotSpec, FrameError>

Return a backend-neutral pandas-style grouped boxplot request (alias for DataFrameGroupBy::boxplot).

Source

pub fn box(&self) -> Result<BoxPlotSpec, FrameError>

Return a backend-neutral pandas-style grouped boxplot request (alias for DataFrameGroupBy::boxplot).

Source

pub fn plot_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe plot directly to deterministic SVG string.

Source

pub fn plot_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe plot directly to HTML figure snippet.

Source

pub fn plot_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe plot directly to disk.

Source

pub fn hist_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe histogram directly to deterministic SVG string.

Source

pub fn hist_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe histogram directly to HTML figure snippet.

Source

pub fn hist_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe histogram directly to disk.

Source

pub fn boxplot_to_svg(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe boxplot directly to deterministic SVG string.

Source

pub fn boxplot_to_html(&self) -> Result<String, FrameError>

Convenience helper: render grouped dataframe boxplot directly to HTML figure snippet.

Source

pub fn boxplot_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe boxplot directly to disk.

Source

pub fn hist_with_bins(&self, bins: usize) -> Result<HistogramSpec, FrameError>

Return a backend-neutral grouped histogram request with a custom number of bins.

Source

pub fn hist_with_bins_to_svg(&self, bins: usize) -> Result<String, FrameError>

Convenience helper: render grouped dataframe histogram with custom bins directly to deterministic SVG string.

Source

pub fn hist_with_bins_to_html(&self, bins: usize) -> Result<String, FrameError>

Convenience helper: render grouped dataframe histogram with custom bins directly to HTML figure snippet.

Source

pub fn hist_with_bins_to_file<P: AsRef<Path>>( &self, bins: usize, path: P, ) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe histogram with custom bins directly to disk.

Source

pub fn hist_columns( &self, columns: &[&str], bins: usize, ) -> Result<HistogramSpec, FrameError>

Return a backend-neutral grouped histogram request restricted to the specified columns with custom bin count.

Source

pub fn hist_columns_to_svg( &self, columns: &[&str], bins: usize, ) -> Result<String, FrameError>

Convenience helper: render grouped dataframe histogram for selected columns directly to deterministic SVG string.

Source

pub fn hist_columns_to_html( &self, columns: &[&str], bins: usize, ) -> Result<String, FrameError>

Convenience helper: render grouped dataframe histogram for selected columns directly to HTML figure snippet.

Source

pub fn hist_columns_to_file<P: AsRef<Path>>( &self, columns: &[&str], bins: usize, path: P, ) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe histogram for selected columns directly to disk.

Source

pub fn boxplot_columns( &self, columns: &[&str], ) -> Result<BoxPlotSpec, FrameError>

Return a backend-neutral grouped boxplot request restricted to the specified columns.

Source

pub fn boxplot_columns_to_svg( &self, columns: &[&str], ) -> Result<String, FrameError>

Convenience helper: render grouped dataframe boxplot for selected columns directly to deterministic SVG string.

Source

pub fn boxplot_columns_to_html( &self, columns: &[&str], ) -> Result<String, FrameError>

Convenience helper: render grouped dataframe boxplot for selected columns directly to HTML figure snippet.

Source

pub fn boxplot_columns_to_file<P: AsRef<Path>>( &self, columns: &[&str], path: P, ) -> Result<(), FrameError>

Convenience helper: save rendered grouped dataframe boxplot for selected columns directly to disk.

Source

pub fn any(&self) -> Result<DataFrame, FrameError>

GroupBy any (returns True if any value is truthy per group).

Source

pub fn all(&self) -> Result<DataFrame, FrameError>

GroupBy all (returns True if all values are truthy per group).

Source

pub fn bool_reduce_with_skipna( &self, all: bool, skipna: bool, ) -> Result<DataFrame, FrameError>

pandas’ any(skipna=...) / all(skipna=...): with skipna=false a missing value is read, as numpy’s bool of NaN, truthy - any of a group holding one is True, and all is unchanged, a skipped value never having made it False (br-frankenpandas-n57tz: the keyword was unexpected). pandas’ nullable dtypes answer <NA> instead (Kleene logic); callers refuse those.

Source

pub fn quantile(&self, q: f64) -> Result<DataFrame, FrameError>

GroupBy quantile.

Source

pub fn sum(&self) -> Result<DataFrame, FrameError>

GroupBy sum.

Source

pub fn mean(&self) -> Result<DataFrame, FrameError>

GroupBy mean.

Source

pub fn count(&self) -> Result<DataFrame, FrameError>

Source

pub fn min(&self) -> Result<DataFrame, FrameError>

GroupBy min.

Source

pub fn max(&self) -> Result<DataFrame, FrameError>

GroupBy max.

Source

pub fn std(&self) -> Result<DataFrame, FrameError>

GroupBy std.

Source

pub fn var(&self) -> Result<DataFrame, FrameError>

GroupBy var.

Source

pub fn median(&self) -> Result<DataFrame, FrameError>

GroupBy median.

Source

pub fn var_ddof(&self, ddof: usize) -> Result<DataFrame, FrameError>

GroupBy variance with pandas’ ddof; var_ddof(1) is var.

Source

pub fn std_ddof(&self, ddof: usize) -> Result<DataFrame, FrameError>

GroupBy standard deviation with pandas’ ddof; std_ddof(1) is std.

Source

pub fn sem_ddof(&self, ddof: usize) -> Result<DataFrame, FrameError>

GroupBy standard error of the mean with pandas’ ddof; sem_ddof(1) is sem.

Source

pub fn first_skipna(&self, skipna: bool) -> Result<DataFrame, FrameError>

pandas’ first(skipna=): with skipna = false each group’s value at its first row, missing or not; first_skipna(true) is first.

Source

pub fn last_skipna(&self, skipna: bool) -> Result<DataFrame, FrameError>

pandas’ last(skipna=): with skipna = false each group’s value at its last row, missing or not; last_skipna(true) is last.

Source

pub fn with_min_count( &self, reduced: DataFrame, min_count: usize, mask_text: bool, ) -> Result<DataFrame, FrameError>

pandas’ min_count on a groupby sum/prod/min/max/first/last already reduced into reduced: a group with fewer than min_count non-missing values gets a missing result (see mask_groups; mask_text = false for min/max, which pandas leaves strings alone under). min_count = 0 changes nothing.

Source

pub fn idxmin(&self) -> Result<DataFrame, FrameError>

Source

pub fn idxmax(&self) -> Result<DataFrame, FrameError>

GroupBy idxmax. Returns the index label of the maximum value for each group.

Source

pub fn first(&self) -> Result<DataFrame, FrameError>

Source

pub fn last(&self) -> Result<DataFrame, FrameError>

GroupBy last.

Source

pub fn nunique(&self) -> Result<DataFrame, FrameError>

Source

pub fn nunique_with_dropna(&self, dropna: bool) -> Result<DataFrame, FrameError>

pandas’ nunique(dropna=...): with dropna=false a group’s missing values count as one more distinct value, column by column - a column’s group has one where its size passes its count (br-frankenpandas-n57tz: the keyword was unexpected).

Source

pub fn prod(&self) -> Result<DataFrame, FrameError>

GroupBy prod (product of non-null values per group).

Source

pub fn agg( &self, func_map: &HashMap<String, String>, ) -> Result<DataFrame, FrameError>

Aggregate with per-column function mapping.

Matches df.groupby(col).agg({'B': 'sum', 'C': 'mean'}) semantics.

func_map: mapping of column_name → aggregation function name. Only the specified columns are included in the output.

Source

pub fn aggregate( &self, func_map: &HashMap<String, String>, ) -> Result<DataFrame, FrameError>

pandas spelling alias for Self::agg.

Source

pub fn agg_list(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>

Aggregate with multiple functions applied to all value columns.

Matches df.groupby(col).agg(['sum', 'mean']) semantics.

Returns a DataFrame where each original value column is expanded into N columns (one per function), named {col}_{func}.

Source

pub fn agg_dict_list( &self, func_map: &[(String, Vec<String>)], ) -> Result<DataFrame, FrameError>

Aggregate with a per-column list of functions.

Matches df.groupby(col).agg({'a': ['sum', 'mean'], 'b': ['min']}) semantics: the result carries a TWO-LEVEL column axis of (input_col, func) tuples, in the order the caller requested, and func_map is an ordered slice rather than a map so that order can be expressed at all.

Storage keeps one column per (input_col, func) pair keyed {col}_{func}, with the tuples alongside in column_multiindex — see Self::with_agg_column_multiindex for why, and Self::agg_dict_list_specs for the measured ordering rule.

Columns absent from the frame are skipped (pandas raises — noted in agg_dict_list_specs), group-by key columns are rejected, and an empty func list is rejected.

Source

pub fn agg_named( &self, specs: &[(&str, &str, &str)], ) -> Result<DataFrame, FrameError>

Named aggregation: each tuple is (output_name, input_column, function).

Matches df.groupby('g').agg(out=('col', 'func')) in pandas. The output DataFrame has columns named by output_name, computed by applying function to input_column within each group.

Example:

ⓘ
let result = df.groupby(&["region"]).unwrap().agg_named(&[
    ("total_sales", "revenue", "sum"),
    ("avg_price", "price", "mean"),
    ("num_orders", "order_id", "count"),
]).unwrap();
Source

pub fn agg_multi( &self, func_map: &[(String, Vec<String>)], ) -> Result<DataFrame, FrameError>

Aggregate with multiple functions per column.

Matches df.groupby(col).agg({'A': ['sum', 'mean'], 'B': ['count']}), returning pandas’ two-level column axis — see Self::agg_dict_list, which this delegates to.

This was a near-verbatim copy of agg_dict_list, differing ONLY in that an empty function list is skipped here and rejected there. It is now that one difference and nothing else, so the column-axis rule cannot drift between the two entry points — which it would have, since the conformance corpus reaches agg_multi while the fp-frame tests reach agg_dict_list. (br-frankenpandas-nv5ct)

Source

pub fn apply<F>(&self, func: F) -> Result<DataFrame, FrameError>

Apply a custom function to each group DataFrame.

Matches pandas 2.x df.groupby(col).apply(func, include_groups=False) for DataFrame-returning functions. Results are concatenated vertically; multi-row group results receive group-key row MultiIndex metadata.

Source

pub fn apply_with_include_groups<F>( &self, include_groups: bool, func: F, ) -> Result<DataFrame, FrameError>

Apply a DataFrame-returning function with explicit include_groups.

Source

pub fn apply_scalar<F>(&self, name: &str, func: F) -> Result<Series, FrameError>

Apply a scalar-returning function to each group.

Rust’s static return types expose pandas’ scalar-returning GroupBy.apply shape as an explicit API: one Series value per group, indexed by the group keys.

Source

pub fn apply_scalar_with_include_groups<F>( &self, name: &str, include_groups: bool, func: F, ) -> Result<Series, FrameError>

Apply a scalar-returning function with explicit include_groups.

Source

pub fn apply_series<F>(&self, func: F) -> Result<DataFrame, FrameError>

Apply a Series-returning function to each group.

Returned Series indexes become output columns. The column union is first-seen ordered and groups missing a Series label receive NaN, which matches pandas’ sparse DataFrame shape for uneven Series returns.

Source

pub fn apply_series_with_include_groups<F>( &self, include_groups: bool, func: F, ) -> Result<DataFrame, FrameError>

Apply a Series-returning function with explicit include_groups.

Source

pub fn apply_series_stacked<F>( &self, name: &str, func: F, ) -> Result<DataFrame, FrameError>

Apply a Series-returning function and stack each returned Series row.

This is the Rust API for pandas’ GroupBy.apply path where returned Series objects do not share identical labels. The result is represented as a one-column DataFrame because Series does not yet carry row MultiIndex metadata; group keys and returned Series labels are retained on the DataFrame row MultiIndex.

Source

pub fn apply_series_stacked_with_include_groups<F>( &self, name: &str, include_groups: bool, func: F, ) -> Result<DataFrame, FrameError>

Apply a stacked Series-returning function with explicit include_groups.

Source

pub fn transform(&self, func_name: &str) -> Result<DataFrame, FrameError>

Source

pub fn transform_list(&self, funcs: &[&str]) -> Result<DataFrame, FrameError>

Transform each group with multiple named aggregation functions.

Matches df.groupby(col).transform(['sum', 'mean']) for the supported function set. One output column is produced per {input_column}_{func} pair, and each aggregated value is broadcast back to the original row positions of its group.

Source

pub fn transform_fn<F>(&self, func: F) -> Result<DataFrame, FrameError>
where F: Fn(&Series) -> Result<Series, FrameError>,

Transform each group using a user-supplied closure.

Matches df.groupby(col).transform(lambda s: ...) — the closure receives a per-group Series (one call per value column × per group) and must return a Series of the same length. Values are scattered back to their original row positions, so the output DataFrame has the same shape and index as the input. Group-by key columns are excluded from the transform (matching pandas). The closure returning a Series whose length differs from its input is rejected.

Source

pub fn size(&self) -> Result<Series, FrameError>

GroupBy size (number of rows per group). Over several keys the result’s index carries the keys’ row MultiIndex, as pandas returns (br-frankenpandas-rc0923-epic-rust-parity-bugs-4qg5w.9).

Source

pub fn filter<F>(&self, func: F) -> Result<DataFrame, FrameError>
where F: Fn(&DataFrame) -> Result<bool, FrameError>,

Filter groups using a function that returns bool for each group.

Analogous to df.groupby(col).filter(func). The function receives a sub-DataFrame for each group and should return true to keep the group or false to drop it. Returns a DataFrame containing only the rows belonging to kept groups, preserving original index and column order.

Source

pub fn cumsum(&self) -> Result<DataFrame, FrameError>

GroupBy cumulative sum. Matches df.groupby(col).cumsum(), dtype included: int64 and bool columns come back int64.

Source

pub fn cumprod(&self) -> Result<DataFrame, FrameError>

GroupBy cumulative product. Matches df.groupby(col).cumprod(), dtype included: int64 and bool columns come back int64.

Source

pub fn cummax(&self) -> Result<DataFrame, FrameError>

GroupBy cumulative max. Matches df.groupby(col).cummax(), dtype included: int64 stays int64, bool stays bool and datetime64 keeps its zone.

Source

pub fn cummin(&self) -> Result<DataFrame, FrameError>

GroupBy cumulative min. Matches df.groupby(col).cummin(), dtype included: int64 stays int64, bool stays bool and datetime64 keeps its zone.

Source

pub fn rank( &self, method: &str, ascending: bool, na_option: &str, ) -> Result<DataFrame, FrameError>

GroupBy rank within each group.

Matches df.groupby(col).rank(). method: “average” (default), “min”, “max”, “first”, “dense” ascending: rank direction (default true = smallest gets rank 1) na_option: “keep” (NaN stays NaN), “top” (NaN gets lowest ranks), “bottom” (NaN gets highest ranks)

Source

pub fn rank_with_pct( &self, method: &str, ascending: bool, na_option: &str, pct: bool, ) -> Result<DataFrame, FrameError>

GroupBy rank within each group and optionally scale the ranks to percentiles.

Source

pub fn shift(&self, periods: i64) -> Result<DataFrame, FrameError>

GroupBy shift within each group.

Matches df.groupby(col).shift(periods).

Source

pub fn diff(&self, periods: i64) -> Result<DataFrame, FrameError>

GroupBy diff within each group.

Matches df.groupby(col).diff(periods).

Source

pub fn nth(&self, n: i64) -> Result<DataFrame, FrameError>

GroupBy nth: select the nth row from each group.

Matches df.groupby(col).nth(n). Returns a DataFrame with one row per group. Negative n counts from the end.

Source

pub fn head(&self, n: i64) -> Result<DataFrame, FrameError>

GroupBy head: select first n rows per group.

Matches df.groupby(col).head(n), including pandas’ negative n: head(-k) keeps all but the last k rows of each group. Verified vs live pandas 2.2.3.

Source

pub fn tail(&self, n: i64) -> Result<DataFrame, FrameError>

GroupBy tail: select last n rows per group.

Matches df.groupby(col).tail(n), including pandas’ negative n: tail(-k) drops the first k rows of each group. Verified vs live pandas 2.2.3.

Source

pub fn take(&self, indices: &[i64]) -> Result<DataFrame, FrameError>

Return positional rows from each group.

Matches pd.DataFrameGroupBy.take(indices), resolving negative positions relative to each group’s length.

Source

pub fn sample( &self, n: Option<usize>, frac: Option<f64>, replace: bool, seed: Option<u64>, ) -> Result<DataFrame, FrameError>

Randomly sample rows from each group.

Matches pd.DataFrameGroupBy.sample(n=..., frac=..., replace=...).

Source

pub fn pct_change(&self, periods: i64) -> Result<DataFrame, FrameError>

GroupBy pct_change within each group.

Matches df.groupby(col).pct_change().

Source

pub fn pct_change_with_fill( &self, periods: i64, fill_method: Option<&str>, limit: Option<usize>, ) -> Result<DataFrame, FrameError>

pandas’ pct_change(periods, fill_method, limit) of each group, column by column (see SeriesGroupBy::pct_change_with_fill).

Source

pub fn value_counts(&self) -> Result<DataFrame, FrameError>

GroupBy value_counts: count of each unique value per group.

Matches df.groupby(col)[value_col].value_counts(). Returns a DataFrame with group key + value as index and counts as values.

Source

pub fn describe(&self) -> Result<DataFrame, FrameError>

GroupBy describe: summary statistics per group.

Matches df.groupby(col).describe(). Returns count, mean, std, min, 25%/50%/75% quantiles, and max for each group’s numeric columns.

Source

pub fn get_group(&self, name: &str) -> Result<DataFrame, FrameError>

Retrieve a single group as a DataFrame.

Matches groupby.get_group(name). The name should match the debug representation of the group key value (e.g. "a" for Utf8 or "Int64(1)" for numeric keys).

Source

pub fn cumcount(&self) -> Result<Series, FrameError>

Assign within-group cumulative count (0-based).

Matches groupby.cumcount(). Returns a Series of Int64 with a monotonically increasing counter within each group.

Source

pub fn cumcount_with_ascending( &self, ascending: bool, ) -> Result<Series, FrameError>

Assign within-group cumulative count (0-based) with explicit direction.

Matches groupby.cumcount(ascending=...).

Source

pub fn ngroup(&self) -> Result<Series, FrameError>

Assign group number to each row.

Matches groupby.ngroup(). Returns a Series of Int64 where each row gets the ordinal number of its group.

Source

pub fn ngroup_with_ascending( &self, ascending: bool, ) -> Result<Series, FrameError>

Source

pub fn pipe<F>(&self, func: F) -> Result<DataFrame, FrameError>
where F: FnOnce(&Self) -> Result<DataFrame, FrameError>,

Pipe the GroupBy through a function.

Matches groupby.pipe(func).

Source

pub fn corr(&self) -> Result<DataFrame, FrameError>

Pairwise Pearson correlation matrix per group.

Matches pd.DataFrameGroupBy.corr() by stacking each group’s DataFrame correlation matrix under group-key row metadata.

Source

pub fn cov(&self) -> Result<DataFrame, FrameError>

Pairwise covariance matrix per group.

Matches pd.DataFrameGroupBy.cov() by stacking each group’s DataFrame covariance matrix under group-key row metadata.

Source

pub fn corrwith(&self, other: &DataFrame) -> Result<DataFrame, FrameError>

Column-wise correlation against another DataFrame per group.

Matches the DataFrameGroupBy.corrwith(other) result shape: one row per group and one column per shared numeric column.

Source

pub fn sem(&self) -> Result<DataFrame, FrameError>

Source

pub fn skew_with_skipna(&self, skipna: bool) -> Result<DataFrame, FrameError>

pandas’ skew(skipna=...): with skipna=false a group holding a missing value in a column is NaN there (br-frankenpandas-n57tz: the keyword was unexpected).

Source

pub fn skew(&self) -> Result<DataFrame, FrameError>

Skewness per group (Fisher’s definition, bias=False).

Matches groupby.skew().

Source

pub fn kurtosis(&self) -> Result<DataFrame, FrameError>

Kurtosis per group (Fisher’s excess, bias=False).

Matches groupby.kurtosis().

Source

pub fn kurt(&self) -> Result<DataFrame, FrameError>

Alias for kurtosis() — pandas exposes both df.groupby(by).kurt() and .kurtosis(). Parity requires both spellings.

Source

pub fn ohlc(&self) -> Result<DataFrame, FrameError>

Open-High-Low-Close per group.

Matches the current FrankenPandas groupby.ohlc() data contract. The returned DataFrame keeps its flat storage column names while carrying the pandas-style column MultiIndex in sidecar metadata.

Source

pub fn ohlc_column_multiindex(&self) -> Result<MultiIndex, FrameError>

pandas-style column MultiIndex for groupby.ohlc().

The first level is the source value column and the second level is one of open, high, low, or close.

Source

pub fn ohlc_with_column_multiindex( &self, ) -> Result<(DataFrame, MultiIndex), FrameError>

Return the current flat OHLC frame plus pandas-style MultiIndex columns.

Source

pub fn ffill(&self, limit: Option<usize>) -> Result<DataFrame, FrameError>

Source

pub fn bfill(&self, limit: Option<usize>) -> Result<DataFrame, FrameError>

Backward-fill missing values within each group.

Matches pd.GroupBy.bfill(). Within each group, fills NaN values with the next non-NaN value.

Source

pub fn fillna(&self, value: &Scalar) -> Result<DataFrame, FrameError>

Fill missing values within each group using a scalar.

Matches pd.GroupBy.fillna(value).

Source

pub fn expanding(&self, min_periods: Option<usize>) -> GroupByExpanding<'_>

Grouped expanding window operations.

Matches pd.DataFrameGroupBy.expanding(min_periods=...).

Source

pub fn ewm(&self, span: Option<f64>, alpha: Option<f64>) -> GroupByEwm<'_>

Grouped exponentially weighted moving window operations.

Matches pd.DataFrameGroupBy.ewm(span=..., alpha=...).

Source

pub fn rolling(&self, window: usize) -> GroupByRolling<'_>

Grouped rolling window operations.

Matches pd.DataFrameGroupBy.rolling(window). Returns a GroupByRolling struct that applies rolling operations per group.

Source

pub fn resample(&self, freq: &str) -> GroupByResample<'_>

Grouped resampling.

Matches pd.DataFrameGroupBy.resample(freq). Returns a GroupByResample struct that applies resampling per group.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for DataFrameGroupBy<'a>

§

impl<'a> !UnwindSafe for DataFrameGroupBy<'a>

§

impl<'a> Forget for DataFrameGroupBy<'a>

§

impl<'a> Freeze for DataFrameGroupBy<'a>

§

impl<'a> Move for DataFrameGroupBy<'a>

§

impl<'a> Send for DataFrameGroupBy<'a>

§

impl<'a> Sync for DataFrameGroupBy<'a>

§

impl<'a> Unpin for DataFrameGroupBy<'a>

§

impl<'a> UnsafeUnpin for DataFrameGroupBy<'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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more