Open
Description
Is your feature request related to a problem?
For a few applications I can think of (e.g. OME-Zarr, single cell data) I (and others) have commonly used integers as the key.
Currently doing this:
import xarray as xr
xr.Dataset({1: xr.DataArray([1, 2])}).to_zarr("test.nc")
Gives this error:
TypeError: Invalid name 1 for DataArray or Dataset key: must be either a string or None for serialization to netCDF or zarr files
Describe the solution you'd like
Xarray handles this behind the scenes for me, saving that key as a str and encoding in the zarr metadata that on open_dataset
it should be restored to an int. This could be generalized to other types as well.
Describe alternatives you've considered
Making an accessor
that handles that conversion, but I'd prefer it just work for as many cases as practicable.
Additional context
No response