maxframe.liteframe.LiteFrame.query#

LiteFrame.query(expr, inplace=False, **kwargs)#

Query the columns of a LiteFrame with a boolean expression.

The boolean expression is evaluated with liteframe_eval() and the resulting single-column boolean LiteFrame is used to filter lf via __getitem__, reusing the existing filter fusion. inplace=True replaces lf’s data with the filtered result.

Parameters:
  • expr (str) – Boolean expression string. Must evaluate to a single boolean column; column names resolve to col() expressions.

  • inplace (bool, default False) – If True, replace lf’s underlying data with the filtered result and return None. If False, return a new filtered LiteFrame.

  • **kwargs – Additional keyword arguments forwarded to liteframe_eval(), such as local_dict, global_dict, and level.

Returns:

Filtered LiteFrame when inplace=False; None when inplace=True (the mutation is applied in place).

Return type:

LiteFrame or None

See also

eval

Evaluate a string expression on LiteFrame columns.

Examples

>>> import maxframe.liteframe as mlf
>>> lf = mlf.LiteFrame({'a': [1, 2, 3, 4, 5], 'b': [10, 20, 30, 40, 50]})

Filter rows where a is greater than 2:

>>> result = lf.query('a > 2')
>>> result.execute()
   a   b
2  3  30
3  4  40
4  5  50

Compound expressions are supported:

>>> result = lf.query('(a > 2) & (b < 50)')
>>> result.execute()
   a   b
2  3  30
3  4  40