Skip to content

Commit 860aad2

Browse files
committed
implement Dataset.pint.to
1 parent 013b056 commit 860aad2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pintxarray/accessors.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,11 @@ def dequantify(self):
374374
}
375375
return Dataset(dequantified_vars, coords=self.ds.coords, attrs=self.ds.attrs)
376376

377+
def to(self, units, **unit_kwargs):
378+
units = either_dict_or_kwargs(units, unit_kwargs, "to")
379+
380+
return conversion.convert_units(self.ds, units)
381+
377382
def to_base_units(self):
378383
base_vars = {name: da.pint.to_base_units() for name, da in self.ds.items()}
379384
return Dataset(base_vars, coords=self.ds.coords, attrs=self.ds.attrs)

0 commit comments

Comments
 (0)