{"action":"created","comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/pulls/comments/198915052","pull_request_review_id":132934387,"id":198915052,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODkxNTA1Mg==","diff_hunk":"@@ -4645,25 +4658,73 @@ def nsmallest(self, n, columns, keep='first'):\n             Number of items to retrieve\n         columns : list or str\n             Column name or names to order by\n-        keep : {'first', 'last'}, default 'first'\n+        keep : {'first', 'last', 'all'}, default 'first'\n             Where there are duplicate values:\n             - ``first`` : take the first occurrence.\n             - ``last`` : take the last occurrence.\n+            - ``all`` : do not drop any duplicates, even it means\n+                        selecting more than `n` items.\n+\n+            .. versionadded:: 0.24.0\n \n         Returns\n         -------\n         DataFrame\n \n         Examples\n         --------\n-        >>> df = pd.DataFrame({'a': [1, 10, 8, 11, -1],\n-        ...                    'b': list('abdce'),\n-        ...                    'c': [1.0, 2.0, np.nan, 3.0, 4.0]})\n+        >>> df = pd.DataFrame({'a': [1, 10, 8, 11, 8, 2],\n+        ...                    'b': list('abdcef'),\n+        ...                    'c': [1.0, 2.0, np.nan, 3.0, 4.0, 9.0]})\n+        >>> df\n+            a  b    c\n+        0   1  a  1.0\n+        1  10  b  2.0\n+        2   8  d  NaN\n+        3  11  c  3.0\n+        4   8  e  4.0\n+        5   2  f  9.0\n+\n+        In the following example, we will use ``nsmallest`` to select the\n+        three rows having the smallest values in column \"a\".\n+\n         >>> df.nsmallest(3, 'a')\n-           a  b   c\n-        4 -1  e   4\n-        0  1  a   1\n-        2  8  d NaN\n+           a  b    c\n+        0  1  a  1.0\n+        5  2  f  9.0\n+        2  8  d  NaN\n+\n+        When using ``keep='last'``, ties are resolved in reverse order:\n+\n+        >>> df.nsmallest(3, 'a', keep='last')\n+           a  b    c\n+        0  1  a  1.0\n+        5  2  f  9.0\n+        4  8  e  4.0\n+\n+        When using ``keep='all'``, all duplicate items are maintained\n+        >>> df.nsmallest(3, 'a', keep='all')\n+           a  b    c\n+        0  1  a  1.0\n+        5  2  f  9.0\n+        2  8  d  NaN\n+        4  8  e  4.0\n+\n+        To order by the largest values in column \"a\" and then \"c\", we can\n+        specify multiple columns like in the next example.\n+\n+        >>> df.nsmallest(3, ['a', 'c'])\n+           a  b    c\n+        0  1  a  1.0\n+        5  2  f  9.0\n+        4  8  e  4.0\n+\n+        Attempting to use ``nsmallest`` on non-numeric dtypes will raise a\n+        ``TypeError``:\n+\n+        >>> df.nsmallest(3, 'b')\n+        Traceback (most recent call last):","path":"pandas/core/frame.py","position":null,"original_position":155,"commit_id":"4998050692991238b26161dd1609f27d3dce42c8","original_commit_id":"a07c686993e94e1f794f3504192a70310bb3af32","user":{"login":"gfyoung","id":9273653,"node_id":"MDQ6VXNlcjkyNzM2NTM=","avatar_url":"https://avatars0.githubusercontent.com/u/9273653?v=4","gravatar_id":"","url":"https://api.github.com/users/gfyoung","html_url":"https://github.com/gfyoung","followers_url":"https://api.github.com/users/gfyoung/followers","following_url":"https://api.github.com/users/gfyoung/following{/other_user}","gists_url":"https://api.github.com/users/gfyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/gfyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfyoung/subscriptions","organizations_url":"https://api.github.com/users/gfyoung/orgs","repos_url":"https://api.github.com/users/gfyoung/repos","events_url":"https://api.github.com/users/gfyoung/events{/privacy}","received_events_url":"https://api.github.com/users/gfyoung/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2018-06-28T17:01:55Z","updated_at":"2018-06-28T17:01:56Z","html_url":"https://github.com/pandas-dev/pandas/pull/21650#discussion_r198915052","pull_request_url":"https://api.github.com/repos/pandas-dev/pandas/pulls/21650","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/comments/198915052"},"html":{"href":"https://github.com/pandas-dev/pandas/pull/21650#discussion_r198915052"},"pull_request":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/21650"}},"in_reply_to_id":198794081},"pull_request":{"url":"https://api.github.com/repos/pandas-dev/pandas/pulls/21650","id":197636472,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3NjM2NDcy","html_url":"https://github.com/pandas-dev/pandas/pull/21650","diff_url":"https://github.com/pandas-dev/pandas/pull/21650.diff","patch_url":"https://github.com/pandas-dev/pandas/pull/21650.patch","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21650","number":21650,"state":"open","locked":false,"title":"ENH: Allow keep='all' for nlargest/nsmallest","user":{"login":"gfyoung","id":9273653,"node_id":"MDQ6VXNlcjkyNzM2NTM=","avatar_url":"https://avatars0.githubusercontent.com/u/9273653?v=4","gravatar_id":"","url":"https://api.github.com/users/gfyoung","html_url":"https://github.com/gfyoung","followers_url":"https://api.github.com/users/gfyoung/followers","following_url":"https://api.github.com/users/gfyoung/following{/other_user}","gists_url":"https://api.github.com/users/gfyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/gfyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfyoung/subscriptions","organizations_url":"https://api.github.com/users/gfyoung/orgs","repos_url":"https://api.github.com/users/gfyoung/repos","events_url":"https://api.github.com/users/gfyoung/events{/privacy}","received_events_url":"https://api.github.com/users/gfyoung/received_events","type":"User","site_admin":false},"body":"Title is self-explanatory.\r\n\r\nCloses #16818.\r\nCloses #18656.\r\n","created_at":"2018-06-27T07:14:39Z","updated_at":"2018-06-28T17:01:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"664f9383d6bd9a9f8e9c2187a8817f3ce0c289a0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":35818298,"node_id":"MDU6TGFiZWwzNTgxODI5OA==","url":"https://api.github.com/repos/pandas-dev/pandas/labels/API%20Design","name":"API Design","color":"AD7FA8","default":false},{"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}],"milestone":{"url":"https://api.github.com/repos/pandas-dev/pandas/milestones/55","html_url":"https://github.com/pandas-dev/pandas/milestone/55","labels_url":"https://api.github.com/repos/pandas-dev/pandas/milestones/55/labels","id":3228419,"node_id":"MDk6TWlsZXN0b25lMzIyODQxOQ==","number":55,"title":"0.24.0","description":"","creator":{"login":"jorisvandenbossche","id":1020496,"node_id":"MDQ6VXNlcjEwMjA0OTY=","avatar_url":"https://avatars2.githubusercontent.com/u/1020496?v=4","gravatar_id":"","url":"https://api.github.com/users/jorisvandenbossche","html_url":"https://github.com/jorisvandenbossche","followers_url":"https://api.github.com/users/jorisvandenbossche/followers","following_url":"https://api.github.com/users/jorisvandenbossche/following{/other_user}","gists_url":"https://api.github.com/users/jorisvandenbossche/gists{/gist_id}","starred_url":"https://api.github.com/users/jorisvandenbossche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jorisvandenbossche/subscriptions","organizations_url":"https://api.github.com/users/jorisvandenbossche/orgs","repos_url":"https://api.github.com/users/jorisvandenbossche/repos","events_url":"https://api.github.com/users/jorisvandenbossche/events{/privacy}","received_events_url":"https://api.github.com/users/jorisvandenbossche/received_events","type":"User","site_admin":false},"open_issues":76,"closed_issues":134,"state":"open","created_at":"2018-03-29T12:00:12Z","updated_at":"2018-06-28T11:15:45Z","due_on":"2018-08-31T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/pandas-dev/pandas/pulls/21650/commits","review_comments_url":"https://api.github.com/repos/pandas-dev/pandas/pulls/21650/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/21650/comments","statuses_url":"https://api.github.com/repos/pandas-dev/pandas/statuses/4998050692991238b26161dd1609f27d3dce42c8","head":{"label":"gfyoung:nlargest-keep-last","ref":"nlargest-keep-last","sha":"4998050692991238b26161dd1609f27d3dce42c8","user":{"login":"gfyoung","id":9273653,"node_id":"MDQ6VXNlcjkyNzM2NTM=","avatar_url":"https://avatars0.githubusercontent.com/u/9273653?v=4","gravatar_id":"","url":"https://api.github.com/users/gfyoung","html_url":"https://github.com/gfyoung","followers_url":"https://api.github.com/users/gfyoung/followers","following_url":"https://api.github.com/users/gfyoung/following{/other_user}","gists_url":"https://api.github.com/users/gfyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/gfyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfyoung/subscriptions","organizations_url":"https://api.github.com/users/gfyoung/orgs","repos_url":"https://api.github.com/users/gfyoung/repos","events_url":"https://api.github.com/users/gfyoung/events{/privacy}","received_events_url":"https://api.github.com/users/gfyoung/received_events","type":"User","site_admin":false},"repo":{"id":51449909,"node_id":"MDEwOlJlcG9zaXRvcnk1MTQ0OTkwOQ==","name":"pandas","full_name":"gfyoung/pandas","owner":{"login":"gfyoung","id":9273653,"node_id":"MDQ6VXNlcjkyNzM2NTM=","avatar_url":"https://avatars0.githubusercontent.com/u/9273653?v=4","gravatar_id":"","url":"https://api.github.com/users/gfyoung","html_url":"https://github.com/gfyoung","followers_url":"https://api.github.com/users/gfyoung/followers","following_url":"https://api.github.com/users/gfyoung/following{/other_user}","gists_url":"https://api.github.com/users/gfyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/gfyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfyoung/subscriptions","organizations_url":"https://api.github.com/users/gfyoung/orgs","repos_url":"https://api.github.com/users/gfyoung/repos","events_url":"https://api.github.com/users/gfyoung/events{/privacy}","received_events_url":"https://api.github.com/users/gfyoung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gfyoung/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/gfyoung/pandas","forks_url":"https://api.github.com/repos/gfyoung/pandas/forks","keys_url":"https://api.github.com/repos/gfyoung/pandas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gfyoung/pandas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gfyoung/pandas/teams","hooks_url":"https://api.github.com/repos/gfyoung/pandas/hooks","issue_events_url":"https://api.github.com/repos/gfyoung/pandas/issues/events{/number}","events_url":"https://api.github.com/repos/gfyoung/pandas/events","assignees_url":"https://api.github.com/repos/gfyoung/pandas/assignees{/user}","branches_url":"https://api.github.com/repos/gfyoung/pandas/branches{/branch}","tags_url":"https://api.github.com/repos/gfyoung/pandas/tags","blobs_url":"https://api.github.com/repos/gfyoung/pandas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gfyoung/pandas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gfyoung/pandas/git/refs{/sha}","trees_url":"https://api.github.com/repos/gfyoung/pandas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gfyoung/pandas/statuses/{sha}","languages_url":"https://api.github.com/repos/gfyoung/pandas/languages","stargazers_url":"https://api.github.com/repos/gfyoung/pandas/stargazers","contributors_url":"https://api.github.com/repos/gfyoung/pandas/contributors","subscribers_url":"https://api.github.com/repos/gfyoung/pandas/subscribers","subscription_url":"https://api.github.com/repos/gfyoung/pandas/subscription","commits_url":"https://api.github.com/repos/gfyoung/pandas/commits{/sha}","git_commits_url":"https://api.github.com/repos/gfyoung/pandas/git/commits{/sha}","comments_url":"https://api.github.com/repos/gfyoung/pandas/comments{/number}","issue_comment_url":"https://api.github.com/repos/gfyoung/pandas/issues/comments{/number}","contents_url":"https://api.github.com/repos/gfyoung/pandas/contents/{+path}","compare_url":"https://api.github.com/repos/gfyoung/pandas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gfyoung/pandas/merges","archive_url":"https://api.github.com/repos/gfyoung/pandas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gfyoung/pandas/downloads","issues_url":"https://api.github.com/repos/gfyoung/pandas/issues{/number}","pulls_url":"https://api.github.com/repos/gfyoung/pandas/pulls{/number}","milestones_url":"https://api.github.com/repos/gfyoung/pandas/milestones{/number}","notifications_url":"https://api.github.com/repos/gfyoung/pandas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gfyoung/pandas/labels{/name}","releases_url":"https://api.github.com/repos/gfyoung/pandas/releases{/id}","deployments_url":"https://api.github.com/repos/gfyoung/pandas/deployments","created_at":"2016-02-10T15:31:30Z","updated_at":"2018-06-28T16:58:27Z","pushed_at":"2018-06-28T17:01:35Z","git_url":"git://github.com/gfyoung/pandas.git","ssh_url":"git@github.com:gfyoung/pandas.git","clone_url":"https://github.com/gfyoung/pandas.git","svn_url":"https://github.com/gfyoung/pandas","homepage":"http://pandas.pydata.org","size":124572,"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":"e0f978d43c960e0af7944a9d7d410662e071c0c7","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","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},"private":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-06-28T16:47:15Z","pushed_at":"2018-06-28T17:01:37Z","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":"http://pandas.pydata.org","size":125533,"stargazers_count":14880,"watchers_count":14880,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5979,"mirror_url":null,"archived":false,"open_issues_count":2734,"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":5979,"open_issues":2734,"watchers":14880,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/21650"},"html":{"href":"https://github.com/pandas-dev/pandas/pull/21650"},"issue":{"href":"https://api.github.com/repos/pandas-dev/pandas/issues/21650"},"comments":{"href":"https://api.github.com/repos/pandas-dev/pandas/issues/21650/comments"},"review_comments":{"href":"https://api.github.com/repos/pandas-dev/pandas/pulls/21650/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/21650/commits"},"statuses":{"href":"https://api.github.com/repos/pandas-dev/pandas/statuses/4998050692991238b26161dd1609f27d3dce42c8"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"gfyoung"}}