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=Truereplaces 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 returnNone. IfFalse, return a new filtered LiteFrame.**kwargs – Additional keyword arguments forwarded to
liteframe_eval(), such aslocal_dict,global_dict, andlevel.
- Returns:
Filtered LiteFrame when
inplace=False;Nonewheninplace=True(the mutation is applied in place).- Return type:
LiteFrame or None
See also
evalEvaluate 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
ais 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