[Python] Why can't I use DataArray.to_zarr() to save a NetCDF format file as Zarr format?

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    I'm not sure if it's a version compatibility issue either. I've spent a lot of time trying but still can't get it to work. Please help me!The codes and mistakes are as follows:

    [in]:
    print(xr.__version__, ' ', zarr.__version__)
    xr.open_dataarray(r'D:\AVISO_SLA_copernicusmarine\SLA_2001.nc'
    ).to_zarr(r'D:\AVISO_SLA_copernicusmarine\SLA_2001111.zarr', mode='w')


    [out]:
    2024.11.0 3.0.7


    TypeError Traceback (most recent call last)
    Cell In[22], line 3
    1 print(xr.__version__, ' ', zarr.__version__)
    2 xr.open_dataarray(r'D:\AVISO_SLA_copernicusmarine\SLA_2001.nc'
    ----> 3 ).to_zarr(r'D:\AVISO_SLA_copernicusmarine\SLA_2001111.zarr', mode='w')

    File c:\Users\Admin\anaconda3\envs\xeofs\Lib\site-packages\xarray\core\dataarray.py:4435, in DataArray.to_zarr(self, store, chunk_store, mode, synchronizer, group, encoding, compute, consolidated, append_dim, region, safe_chunks, storage_options, zarr_version)
    4431 else:
    4432 # No problems with the name - so we're fine!
    4433 dataset = self.to_dataset()
    -> 4435 return to_zarr( # type: ignore[call-overload,misc]
    4436 dataset,
    4437 store=store,
    4438 chunk_store=chunk_store,
    4439 mode=mode,
    4440 synchronizer=synchronizer,
    4441 group=group,
    4442 encoding=encoding,
    4443 compute=compute,
    4444 consolidated=consolidated,
    4445 append_dim=append_dim,
    4446 region=region,
    4447 safe_chunks=safe_chunks,
    4448 storage_options=storage_options,
    ...
    47 f"{name}={arg}"
    48 for name, arg in zip(kwonly_args[:extra_args], args[-extra_args:], strict=False)
    49 ]

    TypeError: Group.create_array() got an unexpected keyword argument 'exists_ok'
    Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

    Continue reading...

Compartilhe esta Página