Skip to main content

DataFrameExprExt

Trait DataFrameExprExt 

Source
pub trait DataFrameExprExt {
    // Required methods
    fn eval(&self, expr_str: &str) -> Result<Series, ExprError>;
    fn eval_with_locals(
        &self,
        expr_str: &str,
        locals: &BTreeMap<String, Scalar>,
    ) -> Result<Series, ExprError>;
    fn eval_value(&self, expr_str: &str) -> Result<EvalValue, ExprError>;
    fn eval_value_with_locals(
        &self,
        expr_str: &str,
        locals: &BTreeMap<String, Scalar>,
    ) -> Result<EvalValue, ExprError>;
    fn query(&self, expr_str: &str) -> Result<DataFrame, ExprError>;
    fn query_with_locals(
        &self,
        expr_str: &str,
        locals: &BTreeMap<String, Scalar>,
    ) -> Result<DataFrame, ExprError>;
}
Expand description

Extension trait that adds eval() and query() methods directly to DataFrame.

Import this trait to call df.eval("a + b") and df.query("a > 1") directly. Uses a default hardened policy and fresh evidence ledger.

Required Methods§

Source

fn eval(&self, expr_str: &str) -> Result<Series, ExprError>

Evaluate an expression string in the context of this DataFrame, as a column of it: an expression naming no column is broadcast to every row, as the right-hand side of an assignment (c = 1) takes it. Self::eval_value answers what pd.DataFrame.eval(expr) returns.

Source

fn eval_with_locals( &self, expr_str: &str, locals: &BTreeMap<String, Scalar>, ) -> Result<Series, ExprError>

Self::eval with explicit @local scalar bindings.

Source

fn eval_value(&self, expr_str: &str) -> Result<EvalValue, ExprError>

Matches pd.DataFrame.eval(expr) without an assignment: a Series, or one value for an expression naming no column (EvalValue).

Source

fn eval_value_with_locals( &self, expr_str: &str, locals: &BTreeMap<String, Scalar>, ) -> Result<EvalValue, ExprError>

Self::eval_value with explicit @local scalar bindings.

Source

fn query(&self, expr_str: &str) -> Result<DataFrame, ExprError>

Filter rows by a boolean expression string.

Matches pd.DataFrame.query(expr).

Source

fn query_with_locals( &self, expr_str: &str, locals: &BTreeMap<String, Scalar>, ) -> Result<DataFrame, ExprError>

Matches pd.DataFrame.query(expr) with explicit @local scalar bindings.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl DataFrameExprExt for DataFrame

Source§

fn eval(&self, expr_str: &str) -> Result<Series, ExprError>

Source§

fn eval_with_locals( &self, expr_str: &str, locals: &BTreeMap<String, Scalar>, ) -> Result<Series, ExprError>

Source§

fn eval_value(&self, expr_str: &str) -> Result<EvalValue, ExprError>

Source§

fn eval_value_with_locals( &self, expr_str: &str, locals: &BTreeMap<String, Scalar>, ) -> Result<EvalValue, ExprError>

Source§

fn query(&self, expr_str: &str) -> Result<DataFrame, ExprError>

Source§

fn query_with_locals( &self, expr_str: &str, locals: &BTreeMap<String, Scalar>, ) -> Result<DataFrame, ExprError>

Implementors§