larch.DataTree.query_cases

larch.DataTree.query_cases

DataTree.query_cases(*args, **kwargs)[source]

Return a new DataTree, with a query filter applied to the root Dataset.

Parameters
  • query (str) – Python expressions to be evaluated against the data variables in the root dataset. The expressions will be evaluated using the pandas eval() function, and can contain any valid Python expressions but cannot contain any Python statements.

  • parser ({"pandas", "python"}, default: "pandas") – The parser to use to construct the syntax tree from the expression. The default of ‘pandas’ parses code slightly different than standard Python. Alternatively, you can parse an expression using the ‘python’ parser to retain strict Python semantics.

  • engine ({"python", "numexpr", None}, default: None) –

    The engine used to evaluate the expression. Supported engines are:

    • None: tries to use numexpr, falls back to python

    • ”numexpr”: evaluates expressions using numexpr

    • ”python”: performs operations as if you had eval’d in top level python

Returns

DataTree – A new DataTree with the same contents as this DataTree, except each array of the root Dataset is indexed by the results of the query on the CASEID dimension.

See also

Dataset.query_cases