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/4825#issuecomment-916974087,https://api.github.com/repos/pydata/xarray/issues/4825,916974087,IC_kwDOAMm_X842p-oH,4160723,2021-09-10T15:04:14Z,2021-09-10T15:04:14Z,MEMBER,"I think that the explicit index refactoring would be an opportunity to clarify things a bit. With no concept of a dimension coordinate/ implicit index, *ideally* we could have the following behavior with a clear distinction between dimensions/coordinates and indexes, following more closely the ""explicit is better than implicit"" principle: - `set_index` / `reset_index` would only affect the indexes without implicitly renaming any coordinate or dimension. - actually, setting a new index for a given dimension doesn't make much sense anymore with the new data model. Setting a new index for a given set of variables and/or coordinates makes more sense - trying to set an index from non-existing data variables or coordinates would raise a `KeyError` - `.reset_index(""x"")` would not rename the `x` coordinate to `x_` - `.set_index(x=""b"")` (where `x` is a dimension without index/coordinate and `b` is a variable with dimension `x`) would be replaced by a more explicit `set_index(""b"").rename({""b"": ""x""})`. Renaming `b` to `x` wouldn't even be necessary if we want to use the `b` coordinate as an index. - `rename_*` would only affect the name of coordinates or dimensions (or the name of the DataArray) without implicitly adding or removing any index. - `.set_coords(""b"").rename({""b"": ""x""})` in the example above would not implictly create an index for the ""x"" coordinate - `swap_dims` would only affect the existing dimension names without implicitly adding or removing any index and without renaming any coordinate. This would be in an ideal world, though. More practically, I don't know how we could make a smooth transition. > There's also rename_dims, but only on a Dataset! There's a TODO to deprecate swap_dims in favor of that. Though I'm not sure that's right — swap_dims changes the dim values for another variable's, but rename_dims just changes the name? `swap_dims` used as a workaround for switching from one to another coordinate as index on a dimension will no longer be needed after the explicit indexes refactoring. Should we eventually depreciate it, then? ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,789106802 https://github.com/pydata/xarray/issues/4825#issuecomment-766933711,https://api.github.com/repos/pydata/xarray/issues/4825,766933711,MDEyOklzc3VlQ29tbWVudDc2NjkzMzcxMQ==,14808389,2021-01-25T16:21:54Z,2021-01-25T16:21:54Z,MEMBER,"if we do 2 I think we should add a `new_dims` kwarg to `reset_index`, otherwise swapping to a dimension without a coordinate is a lot more difficult.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,789106802 https://github.com/pydata/xarray/issues/4825#issuecomment-766914263,https://api.github.com/repos/pydata/xarray/issues/4825,766914263,MDEyOklzc3VlQ29tbWVudDc2NjkxNDI2Mw==,2448579,2021-01-25T15:54:14Z,2021-01-25T15:54:14Z,MEMBER,"> I'm not sure exactly how to rationalize them though. How about 1. `rename_*` should only allow renaming to unused names, 2. `swap_dims` should only work with existing names. 3. `set_index` should raise an error for the ""renaming"" and ""swapping"" cases.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,789106802 https://github.com/pydata/xarray/issues/4825#issuecomment-766429379,https://api.github.com/repos/pydata/xarray/issues/4825,766429379,MDEyOklzc3VlQ29tbWVudDc2NjQyOTM3OQ==,5635139,2021-01-24T20:48:19Z,2021-01-24T20:48:19Z,MEMBER,"There's also `rename_dims`, but only on a Dataset! There's a TODO to deprecate `swap_dims` in favor of that. Though I'm not sure that's right — `swap_dims` changes the dim values for another variable's, but `rename_dims` just changes the name?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,789106802 https://github.com/pydata/xarray/issues/4825#issuecomment-763219168,https://api.github.com/repos/pydata/xarray/issues/4825,763219168,MDEyOklzc3VlQ29tbWVudDc2MzIxOTE2OA==,5635139,2021-01-19T23:53:34Z,2021-01-19T23:53:34Z,MEMBER,"I agree it's confusing, and I find myself looking up the correct way to do something fairly frequently. I'm not sure exactly how to rationalize them though. Without thinking this through in enough detail, Does `set_` set the variable to the relevant type and `reset_` unsets it to a normal variable? In that framework, I _think_ the only aberrant is `swap_dims`, which could instead be `set_dims`?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,789106802