{"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 take='all' 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":142,"closed_issues":45,"state":"open","created_at":"2015-03-23T10:47:38Z","updated_at":"2015-05-30T13:41:38Z","due_on":"2015-06-30T04:00:00Z","closed_at":null},"comments":1,"created_at":"2015-05-30T13:00:05Z","updated_at":"2015-05-30T18:30:55Z","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 ``take`` kw to handle first / last / all duplicates based on the discussion above. If there is better API/kw, please lmk.\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(take='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(take='all')\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(take='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(take='all')\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/107074317","html_url":"https://github.com/pydata/pandas/pull/10236#issuecomment-107074317","issue_url":"https://api.github.com/repos/pydata/pandas/issues/10236","id":107074317,"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},"created_at":"2015-05-30T18:30:55Z","updated_at":"2015-05-30T18:30:55Z","body":"I like this functionality... but I'm not sure about the name/keywords.\r\n\r\n`take='first'` and `take='last'` indicate that the first/last item should be kept. Thus, if no items are kept, it would make more sense to use the value `take='none'` rather than `take='all'`.\r\n\r\nAlso, I'm not sure about the name `take`. I know this is similar to the existing keyword argument `take_last`, but I don't find it very suggestive. I don't know if I have a better alternative, though... maybe `keep`?"}}