xarray icon indicating copy to clipboard operation
xarray copied to clipboard

Add Dataset.subset() method for type-stable variable selection

Open shoyer opened this issue 1 month ago • 1 comments

Addresses issue #3894 by providing a public API for selecting multiple variables that always returns a Dataset (unlike __getitem__) and accepts sequence types including tuples. This eliminates the need to convert tuples to lists when subsetting variables and provides better type stability for downstream code.

Unlike using __getitem__ with a list, an explicit method is more discoverable through IDE autocomplete and documentation.

  • [x] Closes #3894
  • [x] Tests added
  • [x] User visible changes (including notable bug fixes) are documented in whats-new.rst
  • [x] New functions/methods are listed in api.rst

shoyer avatar Nov 21 '25 23:11 shoyer

cc @eni-awowale

keewis avatar Nov 22 '25 11:11 keewis