{"action":"created","comment":{"url":"https://api.github.com/repos/pydata/xarray/pulls/comments/66102218","id":66102218,"diff_hunk":"@@ -39,10 +39,14 @@ Enhancements\n   attributes are retained in the resampled object. By\n   `Jeremy McGibbon <https://github.com/mcgibbon>`_.\n \n+- DataArray and Dataset methods :py:meth:`sel` and :py:meth:`loc` now\n+  accept dictionaries or nested tuples for indexing on multi-index dimensions.\n+  By `Benoit Bovy <https://github.com/benbovy>`_.","path":"doc/whats-new.rst","position":6,"original_position":6,"commit_id":"8895e0429886a713da19a182a3cd00b721c8f79b","original_commit_id":"8895e0429886a713da19a182a3cd00b721c8f79b","user":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"body":"Can you also please add a note about the changed behavior (we now drop levels, which is consistent with pandas) in the \"Breaking changes\" section above?\r\n\r\nAlso, add a reference here to the documentation section you added:\r\n\r\n    :ref:`multi-level indexing`","created_at":"2016-06-07T16:12:12Z","updated_at":"2016-06-07T16:12:12Z","html_url":"https://github.com/pydata/xarray/pull/802#discussion_r66102218","pull_request_url":"https://api.github.com/repos/pydata/xarray/pulls/802","_links":{"self":{"href":"https://api.github.com/repos/pydata/xarray/pulls/comments/66102218"},"html":{"href":"https://github.com/pydata/xarray/pull/802#discussion_r66102218"},"pull_request":{"href":"https://api.github.com/repos/pydata/xarray/pulls/802"}}},"pull_request":{"url":"https://api.github.com/repos/pydata/xarray/pulls/802","id":64042989,"html_url":"https://github.com/pydata/xarray/pull/802","diff_url":"https://github.com/pydata/xarray/pull/802.diff","patch_url":"https://github.com/pydata/xarray/pull/802.patch","issue_url":"https://api.github.com/repos/pydata/xarray/issues/802","number":802,"state":"open","locked":false,"title":"Multi-index indexing","user":{"login":"benbovy","id":4160723,"avatar_url":"https://avatars.githubusercontent.com/u/4160723?v=3","gravatar_id":"","url":"https://api.github.com/users/benbovy","html_url":"https://github.com/benbovy","followers_url":"https://api.github.com/users/benbovy/followers","following_url":"https://api.github.com/users/benbovy/following{/other_user}","gists_url":"https://api.github.com/users/benbovy/gists{/gist_id}","starred_url":"https://api.github.com/users/benbovy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbovy/subscriptions","organizations_url":"https://api.github.com/users/benbovy/orgs","repos_url":"https://api.github.com/users/benbovy/repos","events_url":"https://api.github.com/users/benbovy/events{/privacy}","received_events_url":"https://api.github.com/users/benbovy/received_events","type":"User","site_admin":false},"body":"Follows #767.\r\n\r\nThis is incomplete (it still needs some tests and documentation updates), but it is working for both `Dataset` and `DataArray` objects. I also don't know if it is fully compatible with lazy indexing (Dask). \r\n\r\nUsing the example from #767:\r\n\r\n```\r\nIn [4]: da.sel(band_wavenumber={'band': 'foo'})\r\nOut[4]:\r\n<xarray.DataArray (wavenumber: 2)>\r\narray([ 0.00017,  0.00014])\r\nCoordinates:\r\n  * wavenumber  (wavenumber) float64 4.05e+03 4.05e+03\r\n```\r\n\r\nAs shown in this example, similarily to pandas, it automatically renames the dimension and assigns a new coordinate when the selection doesn't return a `pd.MultiIndex` (here it returns a `pd.FloatIndex`).\r\n\r\nIn some cases this behavior may be unwanted (??), so I added a `drop_level` keyword argument (if `False` it keeps the multi-index and doesn't change the dimension/coordinate names):\r\n\r\n```\r\nIn [5]: da.sel(band_wavenumber={'band': 'foo'}, drop_level=False)\r\nOut[5]:\r\n<xarray.DataArray (band_wavenumber: 2)>\r\narray([ 0.00017,  0.00014])\r\nCoordinates:\r\n  * band_wavenumber  (band_wavenumber) object ('foo', 4050.2) ('foo', 4050.3)\r\n```\r\n\r\nNote that it also works with `DataArray.loc`, but (for now) in that case it always returns the multi-index:\r\n\r\n```\r\nIn [6]: da.loc[{'band_wavenumber': {'band': 'foo'}}]\r\nOut[6]:\r\n<xarray.DataArray (band_wavenumber: 2)>\r\narray([ 0.00017,  0.00014])\r\nCoordinates:\r\n  * band_wavenumber  (band_wavenumber) object ('foo', 4050.2) ('foo', 4050.3)\r\n```\r\n\r\nThis is however inconsistent with `Dataset.sel` and `Dataset.loc` that both apply `drop_level=True` by default, due to their different implementation. Two solutions: (1) make `DataArray.loc` apply drop_level by default, or (2) use `drop_level=False` by default everywhere.","created_at":"2016-03-24T14:39:38Z","updated_at":"2016-06-07T16:12:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4230cb246948b6b7a18c43a1630b610ea71b2a16","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pydata/xarray/pulls/802/commits","review_comments_url":"https://api.github.com/repos/pydata/xarray/pulls/802/comments","review_comment_url":"https://api.github.com/repos/pydata/xarray/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pydata/xarray/issues/802/comments","statuses_url":"https://api.github.com/repos/pydata/xarray/statuses/8895e0429886a713da19a182a3cd00b721c8f79b","head":{"label":"benbovy:multi-index_select","ref":"multi-index_select","sha":"8895e0429886a713da19a182a3cd00b721c8f79b","user":{"login":"benbovy","id":4160723,"avatar_url":"https://avatars.githubusercontent.com/u/4160723?v=3","gravatar_id":"","url":"https://api.github.com/users/benbovy","html_url":"https://github.com/benbovy","followers_url":"https://api.github.com/users/benbovy/followers","following_url":"https://api.github.com/users/benbovy/following{/other_user}","gists_url":"https://api.github.com/users/benbovy/gists{/gist_id}","starred_url":"https://api.github.com/users/benbovy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbovy/subscriptions","organizations_url":"https://api.github.com/users/benbovy/orgs","repos_url":"https://api.github.com/users/benbovy/repos","events_url":"https://api.github.com/users/benbovy/events{/privacy}","received_events_url":"https://api.github.com/users/benbovy/received_events","type":"User","site_admin":false},"repo":{"id":54564452,"name":"xarray","full_name":"benbovy/xarray","owner":{"login":"benbovy","id":4160723,"avatar_url":"https://avatars.githubusercontent.com/u/4160723?v=3","gravatar_id":"","url":"https://api.github.com/users/benbovy","html_url":"https://github.com/benbovy","followers_url":"https://api.github.com/users/benbovy/followers","following_url":"https://api.github.com/users/benbovy/following{/other_user}","gists_url":"https://api.github.com/users/benbovy/gists{/gist_id}","starred_url":"https://api.github.com/users/benbovy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbovy/subscriptions","organizations_url":"https://api.github.com/users/benbovy/orgs","repos_url":"https://api.github.com/users/benbovy/repos","events_url":"https://api.github.com/users/benbovy/events{/privacy}","received_events_url":"https://api.github.com/users/benbovy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/benbovy/xarray","description":"N-D labeled arrays and datasets in Python","fork":true,"url":"https://api.github.com/repos/benbovy/xarray","forks_url":"https://api.github.com/repos/benbovy/xarray/forks","keys_url":"https://api.github.com/repos/benbovy/xarray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benbovy/xarray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benbovy/xarray/teams","hooks_url":"https://api.github.com/repos/benbovy/xarray/hooks","issue_events_url":"https://api.github.com/repos/benbovy/xarray/issues/events{/number}","events_url":"https://api.github.com/repos/benbovy/xarray/events","assignees_url":"https://api.github.com/repos/benbovy/xarray/assignees{/user}","branches_url":"https://api.github.com/repos/benbovy/xarray/branches{/branch}","tags_url":"https://api.github.com/repos/benbovy/xarray/tags","blobs_url":"https://api.github.com/repos/benbovy/xarray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benbovy/xarray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benbovy/xarray/git/refs{/sha}","trees_url":"https://api.github.com/repos/benbovy/xarray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benbovy/xarray/statuses/{sha}","languages_url":"https://api.github.com/repos/benbovy/xarray/languages","stargazers_url":"https://api.github.com/repos/benbovy/xarray/stargazers","contributors_url":"https://api.github.com/repos/benbovy/xarray/contributors","subscribers_url":"https://api.github.com/repos/benbovy/xarray/subscribers","subscription_url":"https://api.github.com/repos/benbovy/xarray/subscription","commits_url":"https://api.github.com/repos/benbovy/xarray/commits{/sha}","git_commits_url":"https://api.github.com/repos/benbovy/xarray/git/commits{/sha}","comments_url":"https://api.github.com/repos/benbovy/xarray/comments{/number}","issue_comment_url":"https://api.github.com/repos/benbovy/xarray/issues/comments{/number}","contents_url":"https://api.github.com/repos/benbovy/xarray/contents/{+path}","compare_url":"https://api.github.com/repos/benbovy/xarray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benbovy/xarray/merges","archive_url":"https://api.github.com/repos/benbovy/xarray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benbovy/xarray/downloads","issues_url":"https://api.github.com/repos/benbovy/xarray/issues{/number}","pulls_url":"https://api.github.com/repos/benbovy/xarray/pulls{/number}","milestones_url":"https://api.github.com/repos/benbovy/xarray/milestones{/number}","notifications_url":"https://api.github.com/repos/benbovy/xarray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benbovy/xarray/labels{/name}","releases_url":"https://api.github.com/repos/benbovy/xarray/releases{/id}","deployments_url":"https://api.github.com/repos/benbovy/xarray/deployments","created_at":"2016-03-23T14:02:27Z","updated_at":"2016-03-23T14:02:28Z","pushed_at":"2016-06-07T15:51:01Z","git_url":"git://github.com/benbovy/xarray.git","ssh_url":"git@github.com:benbovy/xarray.git","clone_url":"https://github.com/benbovy/xarray.git","svn_url":"https://github.com/benbovy/xarray","homepage":"http://xarray.pydata.org","size":6312,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pydata:master","ref":"master","sha":"80abe5dede7bf8a2949139f8ba083a6d74d4e3db","user":{"login":"pydata","id":1284191,"avatar_url":"https://avatars.githubusercontent.com/u/1284191?v=3","gravatar_id":"","url":"https://api.github.com/users/pydata","html_url":"https://github.com/pydata","followers_url":"https://api.github.com/users/pydata/followers","following_url":"https://api.github.com/users/pydata/following{/other_user}","gists_url":"https://api.github.com/users/pydata/gists{/gist_id}","starred_url":"https://api.github.com/users/pydata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydata/subscriptions","organizations_url":"https://api.github.com/users/pydata/orgs","repos_url":"https://api.github.com/users/pydata/repos","events_url":"https://api.github.com/users/pydata/events{/privacy}","received_events_url":"https://api.github.com/users/pydata/received_events","type":"Organization","site_admin":false},"repo":{"id":13221727,"name":"xarray","full_name":"pydata/xarray","owner":{"login":"pydata","id":1284191,"avatar_url":"https://avatars.githubusercontent.com/u/1284191?v=3","gravatar_id":"","url":"https://api.github.com/users/pydata","html_url":"https://github.com/pydata","followers_url":"https://api.github.com/users/pydata/followers","following_url":"https://api.github.com/users/pydata/following{/other_user}","gists_url":"https://api.github.com/users/pydata/gists{/gist_id}","starred_url":"https://api.github.com/users/pydata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydata/subscriptions","organizations_url":"https://api.github.com/users/pydata/orgs","repos_url":"https://api.github.com/users/pydata/repos","events_url":"https://api.github.com/users/pydata/events{/privacy}","received_events_url":"https://api.github.com/users/pydata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pydata/xarray","description":"N-D labeled arrays and datasets in Python","fork":false,"url":"https://api.github.com/repos/pydata/xarray","forks_url":"https://api.github.com/repos/pydata/xarray/forks","keys_url":"https://api.github.com/repos/pydata/xarray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pydata/xarray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pydata/xarray/teams","hooks_url":"https://api.github.com/repos/pydata/xarray/hooks","issue_events_url":"https://api.github.com/repos/pydata/xarray/issues/events{/number}","events_url":"https://api.github.com/repos/pydata/xarray/events","assignees_url":"https://api.github.com/repos/pydata/xarray/assignees{/user}","branches_url":"https://api.github.com/repos/pydata/xarray/branches{/branch}","tags_url":"https://api.github.com/repos/pydata/xarray/tags","blobs_url":"https://api.github.com/repos/pydata/xarray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pydata/xarray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pydata/xarray/git/refs{/sha}","trees_url":"https://api.github.com/repos/pydata/xarray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pydata/xarray/statuses/{sha}","languages_url":"https://api.github.com/repos/pydata/xarray/languages","stargazers_url":"https://api.github.com/repos/pydata/xarray/stargazers","contributors_url":"https://api.github.com/repos/pydata/xarray/contributors","subscribers_url":"https://api.github.com/repos/pydata/xarray/subscribers","subscription_url":"https://api.github.com/repos/pydata/xarray/subscription","commits_url":"https://api.github.com/repos/pydata/xarray/commits{/sha}","git_commits_url":"https://api.github.com/repos/pydata/xarray/git/commits{/sha}","comments_url":"https://api.github.com/repos/pydata/xarray/comments{/number}","issue_comment_url":"https://api.github.com/repos/pydata/xarray/issues/comments{/number}","contents_url":"https://api.github.com/repos/pydata/xarray/contents/{+path}","compare_url":"https://api.github.com/repos/pydata/xarray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pydata/xarray/merges","archive_url":"https://api.github.com/repos/pydata/xarray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pydata/xarray/downloads","issues_url":"https://api.github.com/repos/pydata/xarray/issues{/number}","pulls_url":"https://api.github.com/repos/pydata/xarray/pulls{/number}","milestones_url":"https://api.github.com/repos/pydata/xarray/milestones{/number}","notifications_url":"https://api.github.com/repos/pydata/xarray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pydata/xarray/labels{/name}","releases_url":"https://api.github.com/repos/pydata/xarray/releases{/id}","deployments_url":"https://api.github.com/repos/pydata/xarray/deployments","created_at":"2013-09-30T17:21:10Z","updated_at":"2016-06-01T15:45:14Z","pushed_at":"2016-06-07T15:51:02Z","git_url":"git://github.com/pydata/xarray.git","ssh_url":"git@github.com:pydata/xarray.git","clone_url":"https://github.com/pydata/xarray.git","svn_url":"https://github.com/pydata/xarray","homepage":"http://xarray.pydata.org","size":6618,"stargazers_count":381,"watchers_count":381,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":107,"mirror_url":null,"open_issues_count":169,"forks":107,"open_issues":169,"watchers":381,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pydata/xarray/pulls/802"},"html":{"href":"https://github.com/pydata/xarray/pull/802"},"issue":{"href":"https://api.github.com/repos/pydata/xarray/issues/802"},"comments":{"href":"https://api.github.com/repos/pydata/xarray/issues/802/comments"},"review_comments":{"href":"https://api.github.com/repos/pydata/xarray/pulls/802/comments"},"review_comment":{"href":"https://api.github.com/repos/pydata/xarray/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pydata/xarray/pulls/802/commits"},"statuses":{"href":"https://api.github.com/repos/pydata/xarray/statuses/8895e0429886a713da19a182a3cd00b721c8f79b"}}}}
{"actor":{"display_login":"shoyer"}}