xarray.DataTree.match

Contents

xarray.DataTree.match#

DataTree.match(pattern)[source]#

Return nodes with paths matching pattern.

Uses unix glob-like syntax for pattern-matching.

Parameters

pattern (str) – A pattern to match each node path against.

Returns

DataTree

Examples

>>> dt = DataTree.from_dict(
...     {
...         "/a/A": None,
...         "/a/B": None,
...         "/b/A": None,
...         "/b/B": None,
...     }
... )
>>> dt.match("*/B")
<xarray.DataTree>
Group: /
├── Group: /a
│   └── Group: /a/B
└── Group: /b
    └── Group: /b/B