MCPcopy
hub / github.com/pydata/xarray / query

Method query

xarray/core/dataset.py:9724–9818  ·  view source on GitHub ↗

Return a new dataset with each array indexed along the specified dimension(s), where the indexers are given as strings containing Python expressions to be evaluated against the data variables in the dataset. Parameters ---------- queries : dict-like,

(
        self,
        queries: Mapping[Any, Any] | None = None,
        parser: QueryParserOptions = "pandas",
        engine: QueryEngineOptions = None,
        missing_dims: ErrorOptionsWithWarn = "raise",
        **queries_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

9722 )
9723
9724 def query(
9725 self,
9726 queries: Mapping[Any, Any] | None = None,
9727 parser: QueryParserOptions = "pandas",
9728 engine: QueryEngineOptions = None,
9729 missing_dims: ErrorOptionsWithWarn = "raise",
9730 **queries_kwargs: Any,
9731 ) -> Self:
9732 """Return a new dataset with each array indexed along the specified
9733 dimension(s), where the indexers are given as strings containing
9734 Python expressions to be evaluated against the data variables in the
9735 dataset.
9736
9737 Parameters
9738 ----------
9739 queries : dict-like, optional
9740 A dict-like with keys matching dimensions and values given by strings
9741 containing Python expressions to be evaluated against the data variables
9742 in the dataset. The expressions will be evaluated using the pandas
9743 eval() function, and can contain any valid Python expressions but cannot
9744 contain any Python statements.
9745 parser : {"pandas", "python"}, default: "pandas"
9746 The parser to use to construct the syntax tree from the expression.
9747 The default of 'pandas' parses code slightly different than standard
9748 Python. Alternatively, you can parse an expression using the 'python'
9749 parser to retain strict Python semantics.
9750 engine : {"python", "numexpr", None}, default: None
9751 The engine used to evaluate the expression. Supported engines are:
9752
9753 - None: tries to use numexpr, falls back to python
9754 - "numexpr": evaluates expressions using numexpr
9755 - "python": performs operations as if you had eval’d in top level python
9756
9757 missing_dims : {"raise", "warn", "ignore"}, default: "raise"
9758 What to do if dimensions that should be selected from are not present in the
9759 Dataset:
9760
9761 - "raise": raise an exception
9762 - "warn": raise a warning, and ignore the missing dimensions
9763 - "ignore": ignore the missing dimensions
9764
9765 **queries_kwargs : {dim: query, ...}, optional
9766 The keyword arguments form of ``queries``.
9767 One of queries or queries_kwargs must be provided.
9768
9769 Returns
9770 -------
9771 obj : Dataset
9772 A new Dataset with the same contents as this dataset, except each
9773 array and dimension is indexed by the results of the appropriate
9774 queries.
9775
9776 See Also
9777 --------
9778 Dataset.isel
9779 pandas.eval
9780
9781 Examples

Callers 1

test_queryMethod · 0.95

Calls 5

iselMethod · 0.95
either_dict_or_kwargsFunction · 0.90
typeFunction · 0.85
itemsMethod · 0.80
evalMethod · 0.80

Tested by 1

test_queryMethod · 0.76