{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/10236","labels_url":"https://api.github.com/repos/pydata/pandas/issues/10236/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/10236/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/10236/events","html_url":"https://github.com/pydata/pandas/pull/10236","id":82808102,"number":10236,"title":"ENH: duplicated and drop_duplicates now accept keep kw","user":{"login":"sinhrks","id":1696302,"avatar_url":"https://avatars.githubusercontent.com/u/1696302?v=3","gravatar_id":"","url":"https://api.github.com/users/sinhrks","html_url":"https://github.com/sinhrks","followers_url":"https://api.github.com/users/sinhrks/followers","following_url":"https://api.github.com/users/sinhrks/following{/other_user}","gists_url":"https://api.github.com/users/sinhrks/gists{/gist_id}","starred_url":"https://api.github.com/users/sinhrks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinhrks/subscriptions","organizations_url":"https://api.github.com/users/sinhrks/orgs","repos_url":"https://api.github.com/users/sinhrks/repos","events_url":"https://api.github.com/users/sinhrks/events{/privacy}","received_events_url":"https://api.github.com/users/sinhrks/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Algos","name":"Algos","color":"eb6420"},{"url":"https://api.github.com/repos/pydata/pandas/labels/API%20Design","name":"API Design","color":"AD7FA8"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Indexing","name":"Indexing","color":"0b02e1"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/34","html_url":"https://github.com/pydata/pandas/milestones/0.17.0","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/34/labels","id":1033710,"number":34,"title":"0.17.0","description":"","creator":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"open_issues":181,"closed_issues":228,"state":"open","created_at":"2015-03-23T10:47:38Z","updated_at":"2015-08-08T13:08:42Z","due_on":"2015-08-31T04:00:00Z","closed_at":null},"comments":13,"created_at":"2015-05-30T13:00:05Z","updated_at":"2015-08-08T13:26:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pydata/pandas/pulls/10236","html_url":"https://github.com/pydata/pandas/pull/10236","diff_url":"https://github.com/pydata/pandas/pull/10236.diff","patch_url":"https://github.com/pydata/pandas/pull/10236.patch"},"body":"Closes #6511, Closes #8505.\r\n\r\nIntroduce ``keep`` kw to handle first / last / all duplicates based on the discussion above. If there is better API/kw, please lmk.\r\n\r\n\r\n### ``duplicated``\r\n\r\n- ``keep='first'`` (default): mark duplicates as ``True`` except for the first occurrence.\r\n- ``keep='last'``: mark duplicates as ``True`` except for the last occurrence.\r\n- ``keep=False``: mark all duplicates as ``True``.\r\n\r\n### ``drop_duplicates``\r\n\r\n- ``keep='first'`` (default): drop duplicates except for the first occurrence.\r\n- ``keep='last'``: drop duplicates except for the last occurrence.\r\n- ``keep=False``: drop all duplicates.\r\n\r\n```python\r\nimport pandas as pd\r\ns = pd.Series(['A', 'B', 'C', 'A', 'B', 'D'])\r\n\r\n# mark duplicates except for the first occurrence\r\ns.duplicated()\r\n# 0    False\r\n# 1    False\r\n# 2    False\r\n# 3     True\r\n# 4     True\r\n# 5    False\r\n# dtype: bool\r\n\r\n# mark duplicates except for the last occurrence\r\ns.duplicated(keep='last')\r\n# 0     True\r\n# 1     True\r\n# 2    False\r\n# 3    False\r\n# 4    False\r\n# 5    False\r\n# dtype: bool\r\n\r\n# mark all duplicates\r\ns.duplicated(keep=False)\r\n# 0     True\r\n# 1     True\r\n# 2    False\r\n# 3     True\r\n# 4     True\r\n# 5    False\r\n# dtype: bool\r\n\r\n# drop duplicates except for the first occurrence\r\ns.drop_duplicates()\r\n# 0    A\r\n# 1    B\r\n# 2    C\r\n# 5    D\r\n# dtype: object\r\n\r\n# drop duplicates except for the last occurrence\r\ns.drop_duplicates(keep='last')\r\n# 2    C\r\n# 3    A\r\n# 4    B\r\n# 5    D\r\n# dtype: object\r\n\r\n# drop all duplicates\r\ns.drop_duplicates(keep=False)\r\n# 2    C\r\n# 5    D\r\n# dtype: object\r\n```\r\n\r\nCC @shoyer, @wikiped, @socheon "},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/128981465","html_url":"https://github.com/pydata/pandas/pull/10236#issuecomment-128981465","issue_url":"https://api.github.com/repos/pydata/pandas/issues/10236","id":128981465,"user":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"created_at":"2015-08-08T13:26:21Z","updated_at":"2015-08-08T13:26:21Z","body":"couple of minor comments\r\n\r\nlooks good\r\n\r\nmerge when u r ready "}}