Skip to main content

DataFrameMergeExt

Trait DataFrameMergeExt 

Source
pub trait DataFrameMergeExt {
    // Required methods
    fn merge(
        &self,
        other: &DataFrame,
        on: &[&str],
        how: JoinType,
    ) -> Result<MergedDataFrame, JoinError>;
    fn merge_with_options(
        &self,
        other: &DataFrame,
        left_on: &[&str],
        right_on: &[&str],
        how: JoinType,
        options: MergeExecutionOptions,
    ) -> Result<MergedDataFrame, JoinError>;
    fn join_on_index(
        &self,
        other: &DataFrame,
        how: JoinType,
    ) -> Result<MergedDataFrame, JoinError>;
    fn merge_asof(
        &self,
        other: &DataFrame,
        on: &str,
        direction: &str,
    ) -> Result<MergedDataFrame, JoinError>;
    fn merge_asof_with_options(
        &self,
        other: &DataFrame,
        on: &str,
        direction: &str,
        options: MergeAsofOptions,
    ) -> Result<MergedDataFrame, JoinError>;
    fn merge_ordered(
        &self,
        other: &DataFrame,
        on: &[&str],
        fill_method: Option<&str>,
    ) -> Result<MergedDataFrame, JoinError>;

    // Provided method
    fn join(
        &self,
        other: &DataFrame,
        how: JoinType,
    ) -> Result<MergedDataFrame, JoinError> { ... }
}
Expand description

Extension trait adding .merge() and .join() instance methods to DataFrame.

Import this trait to get pandas-style df.merge(other, ...) and df.join(other, ...) as instance methods.

Required Methods§

Source

fn merge( &self, other: &DataFrame, on: &[&str], how: JoinType, ) -> Result<MergedDataFrame, JoinError>

Merge this DataFrame with another on shared key columns.

Matches pd.DataFrame.merge(other, on=keys, how=join_type).

Source

fn merge_with_options( &self, other: &DataFrame, left_on: &[&str], right_on: &[&str], how: JoinType, options: MergeExecutionOptions, ) -> Result<MergedDataFrame, JoinError>

Merge with separate left/right key columns and execution options.

Matches pd.DataFrame.merge(other, left_on=..., right_on=..., how=...).

Source

fn join_on_index( &self, other: &DataFrame, how: JoinType, ) -> Result<MergedDataFrame, JoinError>

Join another DataFrame on the index.

Matches pd.DataFrame.join(other, how=join_type) (index-based join).

Source

fn merge_asof( &self, other: &DataFrame, on: &str, direction: &str, ) -> Result<MergedDataFrame, JoinError>

Perform an asof merge (nearest-match join) on a sorted key column.

Matches pd.merge_asof(left, right, on=key). Both DataFrames must be sorted by the key column. For each row in left, finds the last row in right where right[on] <= left[on] (backward direction) or the nearest row in the specified direction.

direction: “backward” (default), “forward”, “nearest”.

Source

fn merge_asof_with_options( &self, other: &DataFrame, on: &str, direction: &str, options: MergeAsofOptions, ) -> Result<MergedDataFrame, JoinError>

Perform an asof merge with additional options.

Matches pd.merge_asof(left, right, on=key, direction=..., allow_exact_matches=..., tolerance=..., by=...).

§Parameters
  • other: Right DataFrame to merge with
  • on: Column name to merge on (must be numeric and sorted)
  • direction: “backward”, “forward”, or “nearest”
  • options: Additional options (allow_exact_matches, tolerance, by)
Source

fn merge_ordered( &self, other: &DataFrame, on: &[&str], fill_method: Option<&str>, ) -> Result<MergedDataFrame, JoinError>

Perform an ordered merge (outer join + sort by keys).

Matches pd.merge_ordered(left, right, on=keys, fill_method=...).

Provided Methods§

Source

fn join( &self, other: &DataFrame, how: JoinType, ) -> Result<MergedDataFrame, JoinError>

pandas-named alias for Self::join_on_index. Matches pd.DataFrame.join(other, how=...) directly. Per br-frankenpandas-nk54a.

Default impl delegates to join_on_index. Implementors that already have an optimized index-based join can leave this default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl DataFrameMergeExt for DataFrame

Source§

fn merge( &self, other: &DataFrame, on: &[&str], how: JoinType, ) -> Result<MergedDataFrame, JoinError>

Source§

fn merge_with_options( &self, other: &DataFrame, left_on: &[&str], right_on: &[&str], how: JoinType, options: MergeExecutionOptions, ) -> Result<MergedDataFrame, JoinError>

Source§

fn join_on_index( &self, other: &DataFrame, how: JoinType, ) -> Result<MergedDataFrame, JoinError>

Source§

fn merge_asof( &self, other: &DataFrame, on: &str, direction: &str, ) -> Result<MergedDataFrame, JoinError>

Source§

fn merge_asof_with_options( &self, other: &DataFrame, on: &str, direction: &str, options: MergeAsofOptions, ) -> Result<MergedDataFrame, JoinError>

Source§

fn merge_ordered( &self, other: &DataFrame, on: &[&str], fill_method: Option<&str>, ) -> Result<MergedDataFrame, JoinError>

Implementors§