html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/1949#issuecomment-424025935,https://api.github.com/repos/pydata/xarray/issues/1949,424025935,MDEyOklzc3VlQ29tbWVudDQyNDAyNTkzNQ==,1217238,2018-09-24T15:53:49Z,2018-09-24T15:53:49Z,MEMBER,"> So does this mean that the following line in the docs is now false: ""If a dimension name is given as an argument to drop, it also drops all variables that use that dimension""
Oops -- yes, that line in the docs / example is broken!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,301031693
https://github.com/pydata/xarray/issues/1949#issuecomment-369319591,https://api.github.com/repos/pydata/xarray/issues/1949,369319591,MDEyOklzc3VlQ29tbWVudDM2OTMxOTU5MQ==,1217238,2018-02-28T17:38:59Z,2018-02-28T17:38:59Z,MEMBER,"> The second one also provides more scope to remove subsets of data (all corresponding dims, coords, vars) if the dimension becomes superfluous for any reason, whether or not the dimension is empty.
Yes, this was a useful feature that we lost.
Note that in general we try to encourage using methods to create new Datasets rather than modifying existing ones inplace. So it might also make sense to add a `drop_dims()` method that return a Dataset with the given dimensions removed.","{""total_count"": 3, ""+1"": 3, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,301031693
https://github.com/pydata/xarray/issues/1949#issuecomment-369294450,https://api.github.com/repos/pydata/xarray/issues/1949,369294450,MDEyOklzc3VlQ29tbWVudDM2OTI5NDQ1MA==,1217238,2018-02-28T16:23:40Z,2018-02-28T16:23:40Z,MEMBER,"If you're OK creating a new Dataset, it works to remove any variables using a dimension, e.g.,
```
In [25]: test_dataset = xr.Dataset(dict(
...: empty_array=xr.DataArray([], dims='a'),
...: populated_array=xr.DataArray([1], {'b':['1']}, 'b')
...: ))
...:
In [26]: test_dataset
Out[26]:
Dimensions: (a: 0, b: 1)
Coordinates:
* b (b)
Dimensions: (b: 1)
Coordinates:
* b (b)
Dimensions: (a: 0, b: 1)
Coordinates:
* b (b)
Dimensions: (a: 0, b: 1)
Dimensions without coordinates: a, b
Data variables:
empty_array (a) float64
populated_array (b) int64 1
In [49]: del test_dataset['populated_array']
In [50]: test_dataset
Out[50]:
Dimensions: (a: 0, b: 1)
Dimensions without coordinates: a, b
Data variables:
empty_array (a) float64
```
> Is there a way to remove a dimension (and possibly then all data variables which depend on it)?
This *used* to be possible in the xarray data model prior to v0.9.0. `del` should to delete a dimension corresponding to a coordinate variable and all other associated variables.
When we made coordinates optional, I updated `del` to only delete data/coordinate variables. This made sense, but meant there is now no way to get rid of dimensions.
I'd like to suggest two possible fixes:
1. Update `del dataset[key]` to remove all ""orphaned"" dimensions that don't correspond to a dimension on any variable. This would enforce the invariant ""all dimensions on a dataset correspond to a dimension on one of its variables."" If there are other places where we violate this invariant those should be fixed, too.
2. Update `Dataset.dims` to allow deleting elements. Deleting a dimension on a dataset means all associated variables are also deleted.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,301031693