{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/14432","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/14432/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/14432/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/14432/events","html_url":"https://github.com/pandas-dev/pandas/pull/14432","id":183238446,"number":14432,"title":"ENH: Allow the groupby by param to handle columns and index levels (GH5677)","user":{"login":"jmmease","id":15064365,"avatar_url":"https://avatars.githubusercontent.com/u/15064365?v=3","gravatar_id":"","url":"https://api.github.com/users/jmmease","html_url":"https://github.com/jmmease","followers_url":"https://api.github.com/users/jmmease/followers","following_url":"https://api.github.com/users/jmmease/following{/other_user}","gists_url":"https://api.github.com/users/jmmease/gists{/gist_id}","starred_url":"https://api.github.com/users/jmmease/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmmease/subscriptions","organizations_url":"https://api.github.com/users/jmmease/orgs","repos_url":"https://api.github.com/users/jmmease/repos","events_url":"https://api.github.com/users/jmmease/events{/privacy}","received_events_url":"https://api.github.com/users/jmmease/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pandas-dev/pandas/labels/API%20Design","name":"API Design","color":"AD7FA8"},{"url":"https://api.github.com/repos/pandas-dev/pandas/labels/Groupby","name":"Groupby","color":"729FCF"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-15T23:13:33Z","updated_at":"2016-10-20T00:35:22Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pandas-dev/pandas/pulls/14432","html_url":"https://github.com/pandas-dev/pandas/pull/14432","diff_url":"https://github.com/pandas-dev/pandas/pull/14432.diff","patch_url":"https://github.com/pandas-dev/pandas/pull/14432.patch"},"body":" - [x] closes #5677\r\n - [x] tests added\r\n - [ ] rebase after #14342 is merged to fix #14334\r\n - [ ] tests pass (requires rebase above)\r\n - [x] passes ``git diff upstream/master | flake8 --diff``\r\n - [x] whatsnew entry\r\n - [x] updates existing documentation\r\n\r\nPretty simple change to allow strings passed as the `by` parameter to `df.groupby` to reference columns (existing behavior) or index level names if no column match is found.  Columns take precedence in the case of ambiguity to maintain backward compatibility.\r\n\r\n**Note:** The test case verifying that ambiguity is resolved properly (`test_grouper_column_takes_precedence_over_level`) will not run successfully until bug #14334 is fixed by PR #14342.  I will rebase this branch on upstream/master after this PR is merged.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/254979209","html_url":"https://github.com/pandas-dev/pandas/pull/14432#issuecomment-254979209","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/14432","id":254979209,"user":{"login":"jmmease","id":15064365,"avatar_url":"https://avatars.githubusercontent.com/u/15064365?v=3","gravatar_id":"","url":"https://api.github.com/users/jmmease","html_url":"https://github.com/jmmease","followers_url":"https://api.github.com/users/jmmease/followers","following_url":"https://api.github.com/users/jmmease/following{/other_user}","gists_url":"https://api.github.com/users/jmmease/gists{/gist_id}","starred_url":"https://api.github.com/users/jmmease/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmmease/subscriptions","organizations_url":"https://api.github.com/users/jmmease/orgs","repos_url":"https://api.github.com/users/jmmease/repos","events_url":"https://api.github.com/users/jmmease/events{/privacy}","received_events_url":"https://api.github.com/users/jmmease/received_events","type":"User","site_admin":false},"created_at":"2016-10-20T00:35:22Z","updated_at":"2016-10-20T00:35:22Z","body":"@shoyer\r\nIf we went the deprecation cycle route, would that mean that we'd keep the column precedence behavior but add a `FutureWarning` in the ambiguous case?  Something like the following?\r\n\r\n```.python\r\nwarnings.warn((\"'%s' is both a column name and an index level, defaulting to column.\"\r\n               \"This will raise an ambiguity error in a future version\") % grp,\r\n               FutureWarning, stacklevel=2)\r\n```\r\n\r\nAnd then I assume we'd also add a deprecation note to the whatsnew file.\r\n\r\n@jreback @jorisvandenbossche Thoughts?"}}
{"actor":{"display_login":"jmmease"}}