{"action":"created","comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/pulls/comments/243863797","pull_request_review_id":187736934,"id":243863797,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0Mzg2Mzc5Nw==","diff_hunk":"@@ -698,16 +699,21 @@ def value_counts(values, sort=True, ascending=False, normalize=False,\n             result = Series(values)._values.value_counts(dropna=dropna)\n             result.name = name\n             counts = result.values\n+            uniq = Series(values)._values.unique()\n \n         else:\n             keys, counts = _value_counts_arraylike(values, dropna)\n+            uniq = unique(values)\n \n             if not isinstance(keys, Index):\n                 keys = Index(keys)\n             result = Series(counts, index=keys, name=name)\n \n     if sort:\n         result = result.sort_values(ascending=ascending)\n+    elif bins is None:\n+        if not isinstance(result.index, ABCCategoricalIndex):","path":"pandas/core/algorithms.py","position":30,"original_position":25,"commit_id":"355f872b29fc7eba57379a213562b8e5e5e995bb","original_commit_id":"1dded41fe2666d59de74dddb31fa4032aa8d7473","user":{"login":"tomspur","id":303559,"node_id":"MDQ6VXNlcjMwMzU1OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/303559?v=4","gravatar_id":"","url":"https://api.github.com/users/tomspur","html_url":"https://github.com/tomspur","followers_url":"https://api.github.com/users/tomspur/followers","following_url":"https://api.github.com/users/tomspur/following{/other_user}","gists_url":"https://api.github.com/users/tomspur/gists{/gist_id}","starred_url":"https://api.github.com/users/tomspur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomspur/subscriptions","organizations_url":"https://api.github.com/users/tomspur/orgs","repos_url":"https://api.github.com/users/tomspur/repos","events_url":"https://api.github.com/users/tomspur/events{/privacy}","received_events_url":"https://api.github.com/users/tomspur/received_events","type":"User","site_admin":false},"body":"https://github.com/pandas-dev/pandas/blob/master/pandas/core/arrays/categorical.py#L2267 also mentions that unused categories are not returned.\r\n\r\nIt would be consistent to not return it in the `value_counts` in the above example as well, but would change the current behaviour... What do you think?","created_at":"2018-12-25T01:03:29Z","updated_at":"2018-12-25T01:03:29Z","html_url":"https://github.com/pandas-dev/pandas/pull/24302#discussion_r243863797","pull_request_url":"https://api.github.com/repos/pandas-dev/pandas/pulls/24302","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/comments/243863797"},"html":{"href":"https://github.com/pandas-dev/pandas/pull/24302#discussion_r243863797"},"pull_request":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/24302"}},"in_reply_to_id":243773206},"pull_request":{"url":"https://api.github.com/repos/pandas-dev/pandas/pulls/24302","id":238944483,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4OTQ0NDgz","html_url":"https://github.com/pandas-dev/pandas/pull/24302","diff_url":"https://github.com/pandas-dev/pandas/pull/24302.diff","patch_url":"https://github.com/pandas-dev/pandas/pull/24302.patch","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/24302","number":24302,"state":"open","locked":false,"title":"Series.value_counts: Preserve original ordering","user":{"login":"tomspur","id":303559,"node_id":"MDQ6VXNlcjMwMzU1OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/303559?v=4","gravatar_id":"","url":"https://api.github.com/users/tomspur","html_url":"https://github.com/tomspur","followers_url":"https://api.github.com/users/tomspur/followers","following_url":"https://api.github.com/users/tomspur/following{/other_user}","gists_url":"https://api.github.com/users/tomspur/gists{/gist_id}","starred_url":"https://api.github.com/users/tomspur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomspur/subscriptions","organizations_url":"https://api.github.com/users/tomspur/orgs","repos_url":"https://api.github.com/users/tomspur/repos","events_url":"https://api.github.com/users/tomspur/events{/privacy}","received_events_url":"https://api.github.com/users/tomspur/received_events","type":"User","site_admin":false},"body":"Ensure that value_counts returns the same ordering of the indices than the input object\r\nwhen sorting the values no matter if it is ascending or descending.\r\n\r\n- [x] closes #12679\r\n- [x] tests added / passed\r\n- [x] passes `git diff upstream/master -u -- \"*.py\" | flake8 --diff`\r\n- [x] whatsnew entry\r\n- [ ] About 10 tests of the testsuite are currently failing and I hope to find a fix for them soon as well. Wanted to put up this PR now already to get feedback on the current implementation as well.","created_at":"2018-12-16T03:26:07Z","updated_at":"2018-12-25T01:03:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf2a0148aec25413e30ff429e3bce8b6a42358b0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":57296398,"node_id":"MDU6TGFiZWw1NzI5NjM5OA==","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Algos","name":"Algos","color":"eb6420","default":false},{"id":76812,"node_id":"MDU6TGFiZWw3NjgxMg==","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Enhancement","name":"Enhancement","color":"4E9A06","default":false},{"id":13098779,"node_id":"MDU6TGFiZWwxMzA5ODc3OQ==","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Reshaping","name":"Reshaping","color":"02d7e1","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pandas-dev/pandas/pulls/24302/commits","review_comments_url":"https://api.github.com/repos/pandas-dev/pandas/pulls/24302/comments","review_comment_url":"https://api.github.com/repos/pandas-dev/pandas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/24302/comments","statuses_url":"https://api.github.com/repos/pandas-dev/pandas/statuses/355f872b29fc7eba57379a213562b8e5e5e995bb","head":{"label":"tomspur:series_ordering","ref":"series_ordering","sha":"355f872b29fc7eba57379a213562b8e5e5e995bb","user":{"login":"tomspur","id":303559,"node_id":"MDQ6VXNlcjMwMzU1OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/303559?v=4","gravatar_id":"","url":"https://api.github.com/users/tomspur","html_url":"https://github.com/tomspur","followers_url":"https://api.github.com/users/tomspur/followers","following_url":"https://api.github.com/users/tomspur/following{/other_user}","gists_url":"https://api.github.com/users/tomspur/gists{/gist_id}","starred_url":"https://api.github.com/users/tomspur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomspur/subscriptions","organizations_url":"https://api.github.com/users/tomspur/orgs","repos_url":"https://api.github.com/users/tomspur/repos","events_url":"https://api.github.com/users/tomspur/events{/privacy}","received_events_url":"https://api.github.com/users/tomspur/received_events","type":"User","site_admin":false},"repo":{"id":87242344,"node_id":"MDEwOlJlcG9zaXRvcnk4NzI0MjM0NA==","name":"pandas","full_name":"tomspur/pandas","private":false,"owner":{"login":"tomspur","id":303559,"node_id":"MDQ6VXNlcjMwMzU1OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/303559?v=4","gravatar_id":"","url":"https://api.github.com/users/tomspur","html_url":"https://github.com/tomspur","followers_url":"https://api.github.com/users/tomspur/followers","following_url":"https://api.github.com/users/tomspur/following{/other_user}","gists_url":"https://api.github.com/users/tomspur/gists{/gist_id}","starred_url":"https://api.github.com/users/tomspur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomspur/subscriptions","organizations_url":"https://api.github.com/users/tomspur/orgs","repos_url":"https://api.github.com/users/tomspur/repos","events_url":"https://api.github.com/users/tomspur/events{/privacy}","received_events_url":"https://api.github.com/users/tomspur/received_events","type":"User","site_admin":false},"html_url":"https://github.com/tomspur/pandas","description":"Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more","fork":true,"url":"https://api.github.com/repos/tomspur/pandas","forks_url":"https://api.github.com/repos/tomspur/pandas/forks","keys_url":"https://api.github.com/repos/tomspur/pandas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tomspur/pandas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tomspur/pandas/teams","hooks_url":"https://api.github.com/repos/tomspur/pandas/hooks","issue_events_url":"https://api.github.com/repos/tomspur/pandas/issues/events{/number}","events_url":"https://api.github.com/repos/tomspur/pandas/events","assignees_url":"https://api.github.com/repos/tomspur/pandas/assignees{/user}","branches_url":"https://api.github.com/repos/tomspur/pandas/branches{/branch}","tags_url":"https://api.github.com/repos/tomspur/pandas/tags","blobs_url":"https://api.github.com/repos/tomspur/pandas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tomspur/pandas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tomspur/pandas/git/refs{/sha}","trees_url":"https://api.github.com/repos/tomspur/pandas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tomspur/pandas/statuses/{sha}","languages_url":"https://api.github.com/repos/tomspur/pandas/languages","stargazers_url":"https://api.github.com/repos/tomspur/pandas/stargazers","contributors_url":"https://api.github.com/repos/tomspur/pandas/contributors","subscribers_url":"https://api.github.com/repos/tomspur/pandas/subscribers","subscription_url":"https://api.github.com/repos/tomspur/pandas/subscription","commits_url":"https://api.github.com/repos/tomspur/pandas/commits{/sha}","git_commits_url":"https://api.github.com/repos/tomspur/pandas/git/commits{/sha}","comments_url":"https://api.github.com/repos/tomspur/pandas/comments{/number}","issue_comment_url":"https://api.github.com/repos/tomspur/pandas/issues/comments{/number}","contents_url":"https://api.github.com/repos/tomspur/pandas/contents/{+path}","compare_url":"https://api.github.com/repos/tomspur/pandas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tomspur/pandas/merges","archive_url":"https://api.github.com/repos/tomspur/pandas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tomspur/pandas/downloads","issues_url":"https://api.github.com/repos/tomspur/pandas/issues{/number}","pulls_url":"https://api.github.com/repos/tomspur/pandas/pulls{/number}","milestones_url":"https://api.github.com/repos/tomspur/pandas/milestones{/number}","notifications_url":"https://api.github.com/repos/tomspur/pandas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tomspur/pandas/labels{/name}","releases_url":"https://api.github.com/repos/tomspur/pandas/releases{/id}","deployments_url":"https://api.github.com/repos/tomspur/pandas/deployments","created_at":"2017-04-04T22:48:53Z","updated_at":"2018-12-15T22:51:31Z","pushed_at":"2018-12-23T20:34:33Z","git_url":"git://github.com/tomspur/pandas.git","ssh_url":"git@github.com:tomspur/pandas.git","clone_url":"https://github.com/tomspur/pandas.git","svn_url":"https://github.com/tomspur/pandas","homepage":"http://pandas.pydata.org","size":139840,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pandas-dev:master","ref":"master","sha":"1cd077a3077352d63c1226d554db1e46cb9d2c1a","user":{"login":"pandas-dev","id":21206976,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMjA2OTc2","avatar_url":"https://avatars2.githubusercontent.com/u/21206976?v=4","gravatar_id":"","url":"https://api.github.com/users/pandas-dev","html_url":"https://github.com/pandas-dev","followers_url":"https://api.github.com/users/pandas-dev/followers","following_url":"https://api.github.com/users/pandas-dev/following{/other_user}","gists_url":"https://api.github.com/users/pandas-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/pandas-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pandas-dev/subscriptions","organizations_url":"https://api.github.com/users/pandas-dev/orgs","repos_url":"https://api.github.com/users/pandas-dev/repos","events_url":"https://api.github.com/users/pandas-dev/events{/privacy}","received_events_url":"https://api.github.com/users/pandas-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":858127,"node_id":"MDEwOlJlcG9zaXRvcnk4NTgxMjc=","name":"pandas","full_name":"pandas-dev/pandas","private":false,"owner":{"login":"pandas-dev","id":21206976,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMjA2OTc2","avatar_url":"https://avatars2.githubusercontent.com/u/21206976?v=4","gravatar_id":"","url":"https://api.github.com/users/pandas-dev","html_url":"https://github.com/pandas-dev","followers_url":"https://api.github.com/users/pandas-dev/followers","following_url":"https://api.github.com/users/pandas-dev/following{/other_user}","gists_url":"https://api.github.com/users/pandas-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/pandas-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pandas-dev/subscriptions","organizations_url":"https://api.github.com/users/pandas-dev/orgs","repos_url":"https://api.github.com/users/pandas-dev/repos","events_url":"https://api.github.com/users/pandas-dev/events{/privacy}","received_events_url":"https://api.github.com/users/pandas-dev/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pandas-dev/pandas","description":"Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more","fork":false,"url":"https://api.github.com/repos/pandas-dev/pandas","forks_url":"https://api.github.com/repos/pandas-dev/pandas/forks","keys_url":"https://api.github.com/repos/pandas-dev/pandas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pandas-dev/pandas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pandas-dev/pandas/teams","hooks_url":"https://api.github.com/repos/pandas-dev/pandas/hooks","issue_events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/events{/number}","events_url":"https://api.github.com/repos/pandas-dev/pandas/events","assignees_url":"https://api.github.com/repos/pandas-dev/pandas/assignees{/user}","branches_url":"https://api.github.com/repos/pandas-dev/pandas/branches{/branch}","tags_url":"https://api.github.com/repos/pandas-dev/pandas/tags","blobs_url":"https://api.github.com/repos/pandas-dev/pandas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pandas-dev/pandas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pandas-dev/pandas/git/refs{/sha}","trees_url":"https://api.github.com/repos/pandas-dev/pandas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pandas-dev/pandas/statuses/{sha}","languages_url":"https://api.github.com/repos/pandas-dev/pandas/languages","stargazers_url":"https://api.github.com/repos/pandas-dev/pandas/stargazers","contributors_url":"https://api.github.com/repos/pandas-dev/pandas/contributors","subscribers_url":"https://api.github.com/repos/pandas-dev/pandas/subscribers","subscription_url":"https://api.github.com/repos/pandas-dev/pandas/subscription","commits_url":"https://api.github.com/repos/pandas-dev/pandas/commits{/sha}","git_commits_url":"https://api.github.com/repos/pandas-dev/pandas/git/commits{/sha}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/comments{/number}","issue_comment_url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments{/number}","contents_url":"https://api.github.com/repos/pandas-dev/pandas/contents/{+path}","compare_url":"https://api.github.com/repos/pandas-dev/pandas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pandas-dev/pandas/merges","archive_url":"https://api.github.com/repos/pandas-dev/pandas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pandas-dev/pandas/downloads","issues_url":"https://api.github.com/repos/pandas-dev/pandas/issues{/number}","pulls_url":"https://api.github.com/repos/pandas-dev/pandas/pulls{/number}","milestones_url":"https://api.github.com/repos/pandas-dev/pandas/milestones{/number}","notifications_url":"https://api.github.com/repos/pandas-dev/pandas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pandas-dev/pandas/labels{/name}","releases_url":"https://api.github.com/repos/pandas-dev/pandas/releases{/id}","deployments_url":"https://api.github.com/repos/pandas-dev/pandas/deployments","created_at":"2010-08-24T01:37:33Z","updated_at":"2018-12-25T00:41:48Z","pushed_at":"2018-12-25T00:53:31Z","git_url":"git://github.com/pandas-dev/pandas.git","ssh_url":"git@github.com:pandas-dev/pandas.git","clone_url":"https://github.com/pandas-dev/pandas.git","svn_url":"https://github.com/pandas-dev/pandas","homepage":"https://pandas.pydata.org","size":141043,"stargazers_count":17494,"watchers_count":17494,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7015,"mirror_url":null,"archived":false,"open_issues_count":2823,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":7015,"open_issues":2823,"watchers":17494,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/24302"},"html":{"href":"https://github.com/pandas-dev/pandas/pull/24302"},"issue":{"href":"https://api.github.com/repos/pandas-dev/pandas/issues/24302"},"comments":{"href":"https://api.github.com/repos/pandas-dev/pandas/issues/24302/comments"},"review_comments":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/24302/comments"},"review_comment":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/24302/commits"},"statuses":{"href":"https://api.github.com/repos/pandas-dev/pandas/statuses/355f872b29fc7eba57379a213562b8e5e5e995bb"}},"author_association":"NONE"}}
{"actor":{"display_login":"tomspur"}}