Return a new data array indexed along the specified dimension(s), where the indexers are given as strings containing Python expressions to be evaluated against the values in the array. Parameters ---------- queries : dict-like or None, optional A
(
self,
queries: Mapping[Any, Any] | None = None,
parser: QueryParserOptions = "pandas",
engine: QueryEngineOptions = None,
missing_dims: ErrorOptionsWithWarn = "raise",
**queries_kwargs: Any,
)
| 6443 | return self._replace_maybe_drop_dims(result) |
| 6444 | |
| 6445 | def query( |
| 6446 | self, |
| 6447 | queries: Mapping[Any, Any] | None = None, |
| 6448 | parser: QueryParserOptions = "pandas", |
| 6449 | engine: QueryEngineOptions = None, |
| 6450 | missing_dims: ErrorOptionsWithWarn = "raise", |
| 6451 | **queries_kwargs: Any, |
| 6452 | ) -> DataArray: |
| 6453 | """Return a new data array indexed along the specified |
| 6454 | dimension(s), where the indexers are given as strings containing |
| 6455 | Python expressions to be evaluated against the values in the array. |
| 6456 | |
| 6457 | Parameters |
| 6458 | ---------- |
| 6459 | queries : dict-like or None, optional |
| 6460 | A dict-like with keys matching dimensions and values given by strings |
| 6461 | containing Python expressions to be evaluated against the data variables |
| 6462 | in the dataset. The expressions will be evaluated using the pandas |
| 6463 | eval() function, and can contain any valid Python expressions but cannot |
| 6464 | contain any Python statements. |
| 6465 | parser : {"pandas", "python"}, default: "pandas" |
| 6466 | The parser to use to construct the syntax tree from the expression. |
| 6467 | The default of 'pandas' parses code slightly different than standard |
| 6468 | Python. Alternatively, you can parse an expression using the 'python' |
| 6469 | parser to retain strict Python semantics. |
| 6470 | engine : {"python", "numexpr", None}, default: None |
| 6471 | The engine used to evaluate the expression. Supported engines are: |
| 6472 | |
| 6473 | - None: tries to use numexpr, falls back to python |
| 6474 | - "numexpr": evaluates expressions using numexpr |
| 6475 | - "python": performs operations as if you had eval’d in top level python |
| 6476 | |
| 6477 | missing_dims : {"raise", "warn", "ignore"}, default: "raise" |
| 6478 | What to do if dimensions that should be selected from are not present in the |
| 6479 | DataArray: |
| 6480 | |
| 6481 | - "raise": raise an exception |
| 6482 | - "warn": raise a warning, and ignore the missing dimensions |
| 6483 | - "ignore": ignore the missing dimensions |
| 6484 | |
| 6485 | **queries_kwargs : {dim: query, ...}, optional |
| 6486 | The keyword arguments form of ``queries``. |
| 6487 | One of queries or queries_kwargs must be provided. |
| 6488 | |
| 6489 | Returns |
| 6490 | ------- |
| 6491 | obj : DataArray |
| 6492 | A new DataArray with the same contents as this dataset, indexed by |
| 6493 | the results of the appropriate queries. |
| 6494 | |
| 6495 | See Also |
| 6496 | -------- |
| 6497 | DataArray.isel |
| 6498 | Dataset.query |
| 6499 | pandas.eval |
| 6500 | |
| 6501 | Examples |
| 6502 | -------- |