issues: 611879581
This data as json
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
611879581 | MDU6SXNzdWU2MTE4Nzk1ODE= | 4027 | Bug in the conversion of Pandas DataFrame into Xarray Dataset . | 10154151 | closed | 0 | 6 | 2020-05-04T13:34:32Z | 2020-05-07T13:50:07Z | 2020-05-07T13:50:07Z | NONE | For an unknown reason, the DataSet coordinates don't appear to be in the same order as the Variable dimension when the DataSet is created from a multi-level DataFrame generated by the concatenation of two DataSeries. In this case, the DataSet coordinates have not been sorted by ascending order at the creation of the DataSet (using the DataFrame.to_xarray method). Interestingly, this problem doesnt occur if the original Multi-level DataFrame is generated using the grouby() method. A notebook presenting the issue can be downloaded [here] (https://github.com/lhoupert/xarraytest_lh) MCVE Code Sample
Expected Output
Problem DescriptionThe current output is:
For an unknown reason, the DataSet created from the conversion of the DataFrame dfs1 is wrong. For example, the data indexed as station IB23:
... doesn't correspond to the original DataFrame data:
But it appears to be the data corresponding to Station 10G in the original DataFrame
NotesThe problem appears to be in the DataSet coordinate Staname which has bot been sorted by ascending order while the Data Variable appear to have been sorted differently. The original multi-level DataFrame has been generated by the concatenation of two DataSeries. Interestingly, this problem doesnt occur if the original Multi-level DataFrame is generated using the grouby() method... A notebook presenting the issue can be downloaded [here] (https://github.com/lhoupert/xarraytest_lh) VersionsOutput of <tt>xr.show_versions()</tt>INSTALLED VERSIONS ------------------ commit: None python: 3.8.2 | packaged by conda-forge | (default, Mar 23 2020, 17:55:48) [Clang 9.0.1 ] python-bits: 64 OS: Darwin OS-release: 18.7.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.4 xarray: 0.15.1 pandas: 1.0.3 numpy: 1.18.1 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.1.1.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: 2.4.0 bottleneck: None dask: 2.14.0 distributed: 2.14.0 matplotlib: 3.2.1 cartopy: 0.17.0 seaborn: 0.10.0 numbagg: None setuptools: 46.1.3.post20200325 pip: 20.0.2 conda: None pytest: 5.4.1 IPython: 7.13.0 sphinx: None |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/4027/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |