id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 1827010471,I_kwDOAMm_X85s5fen,8029,' ' at end of variable name causes to_netcdf() to crash,18679628,closed,0,,,6,2023-07-28T19:48:53Z,2023-08-14T16:15:40Z,2023-08-14T16:15:40Z,NONE,,,,"### What happened? If variable name ends in a ' ' (space) then to_netcdf crashes. In my opinion - At least the error message could tell which variable name has the issue - If space at the end is not allowed, then could you rstrip everything - It works with scipy xarr.to_netcdf(newName, engine=""scipy"") This is related to https://github.com/pydata/xarray/issues/7943 Our tool converts csv files to XARRAY. So these kind of errors need to self-heal, otherwise we have to feedback to the user and get them to change the csv file. Which would be frustrating for everyone ### What did you expect to happen? _No response_ ### Minimal Complete Verifiable Example ```Python with open('endSpace.csv','w') as f: f.write('''PASS ,temperature PASS, 10 FAIL, 20''') import pandas as pd df = pd.read_csv('endSpace.csv') index = ['temperature'] df = df.set_index(index) xarr = df.to_xarray() xarr.to_netcdf(""new.nc"") ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. ### Relevant log output ```Python Traceback (most recent call last): File ""/Users/will/Documents/GitHub/czdashboard/old/coordNameBug.py"", line 11, in xarr.to_netcdf(""new.nc"") File ""/opt/homebrew/lib/python3.11/site-packages/xarray/core/dataset.py"", line 1911, in to_netcdf return to_netcdf( # type: ignore # mypy cannot resolve the overloads:( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ""/opt/homebrew/lib/python3.11/site-packages/xarray/backends/api.py"", line 1217, in to_netcdf dump_to_store( File ""/opt/homebrew/lib/python3.11/site-packages/xarray/backends/api.py"", line 1264, in dump_to_store store.store(variables, attrs, check_encoding, writer, unlimited_dims=unlimited_dims) File ""/opt/homebrew/lib/python3.11/site-packages/xarray/backends/common.py"", line 271, in store self.set_variables( File ""/opt/homebrew/lib/python3.11/site-packages/xarray/backends/common.py"", line 309, in set_variables target, source = self.prepare_variable( ^^^^^^^^^^^^^^^^^^^^^^ File ""/opt/homebrew/lib/python3.11/site-packages/xarray/backends/netCDF4_.py"", line 488, in prepare_variable nc4_var = self.ds.createVariable( ^^^^^^^^^^^^^^^^^^^^^^^ File ""src/netCDF4/_netCDF4.pyx"", line 2945, in netCDF4._netCDF4.Dataset.createVariable File ""src/netCDF4/_netCDF4.pyx"", line 4164, in netCDF4._netCDF4.Variable.__init__ File ""src/netCDF4/_netCDF4.pyx"", line 2014, in netCDF4._netCDF4._ensure_nc_success RuntimeError: NetCDF: Name contains illegal characters ``` ### Anything else we need to know? _No response_ ### Environment
commit : 2e218d10984e9919f0296931d92ea851c6a6faf5 python : 3.11.2.final.0 python-bits : 64 OS : Darwin OS-release : 22.5.0 Version : Darwin Kernel Version 22.5.0: Thu Jun 8 22:21:34 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8112 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 1.5.3 numpy : 1.24.2 pytz : 2023.3 dateutil : 2.8.2 setuptools : 65.6.3 pip : 23.1.1 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : None pandas_datareader: None bs4 : None bottleneck : None brotli : None fastparquet : None fsspec : 2023.3.0 gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : 1.10.1 snappy : None sqlalchemy : None tables : None tabulate : None xarray : 2023.2.0 xlrd : None xlwt : None zstandard : None tzdata : None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8029/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 1775325545,I_kwDOAMm_X85p0VFp,7943,'/' in variable name causes to_netcdf() to crash,18679628,closed,0,,,8,2023-06-26T18:17:18Z,2023-07-06T15:11:51Z,2023-07-06T15:11:51Z,NONE,,,,"### What happened? If variable name includes a '/' then to_netcdf crashes ### What did you expect to happen? _No response_ ### Minimal Complete Verifiable Example ```Python import pandas as pd df = pd.read_csv('slashCSV.csv') index = ['temperature'] df = df.set_index(index) xarr = df.to_xarray() xarr.to_netcdf(""new.nc"") - slashCSV.csv contents: PASS/FAIL,temperature PASS, 10 FAIL, 20 ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. ### Relevant log output ```Python File ""/opt/homebrew/lib/python3.11/site-packages/xarray/backends/netCDF4_.py"", line 56, in __init__ array = self.get_array() ^^^^^^^^^^^^^^^^ File ""/opt/homebrew/lib/python3.11/site-packages/xarray/backends/netCDF4_.py"", line 83, in get_array variable = ds.variables[self.variable_name] ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ KeyError: 'PASS/FAIL' ``` ### Anything else we need to know? _No response_ ### Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.11.2 (main, Mar 24 2023, 00:16:47) [Clang 14.0.0 (clang-1400.0.29.202)] python-bits: 64 OS: Darwin OS-release: 22.5.0 machine: arm64 processor: arm byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.2 libnetcdf: 4.9.1 xarray: 2023.2.0 pandas: 1.5.3 numpy: 1.24.2 scipy: 1.10.1 netCDF4: 1.6.3 pydap: None h5netcdf: 1.1.0 h5py: 3.8.0 Nio: None zarr: 2.14.2 cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None rasterio: 1.3.6 cfgrib: 0.9.10.3 iris: None bottleneck: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None fsspec: 2023.3.0 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.6.3 pip: 23.1.1 conda: None pytest: None mypy: None IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7943/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 1649994877,I_kwDOAMm_X85iWOx9,7705,"Using xarray in Docker on a mac fails with ""No such file or directory: 'gdal-config'""",18679628,closed,0,,,6,2023-03-31T20:35:22Z,2023-05-04T20:07:27Z,2023-04-03T15:52:04Z,NONE,,,,"### What is your issue? Hi, This is my docker file ""Dockerfile"": ``` FROM python:3.11.2-slim RUN /usr/local/bin/python -m pip install --upgrade pip RUN pip install xarray[io] ``` Which is built with this command: `docker build -t ""name:Dockerfile"" .` My docker version is: `Docker version 20.10.23, build 7155243` And I'm running macOS Ventura 13.3 Error message: ``` #6 11.79 Downloading rasterio-1.3.6.tar.gz (408 kB) #6 11.83 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 408.5/408.5 kB 12.4 MB/s eta 0:00:00 #6 11.86 Installing build dependencies: started #6 14.05 Installing build dependencies: finished with status 'done' #6 14.05 Getting requirements to build wheel: started #6 14.17 Getting requirements to build wheel: finished with status 'error' #6 14.17 error: subprocess-exited-with-error #6 14.17 #6 14.17 × Getting requirements to build wheel did not run successfully. #6 14.17 │ exit code: 1 #6 14.17 ╰─> [2 lines of output] #6 14.17 WARNING:root:Failed to get options via gdal-config: [Errno 2] No such file or directory: 'gdal-config' #6 14.17 ERROR: A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable. #6 14.17 [end of output] ```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7705/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue