{"action":"closed","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/9467","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/9467/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/9467/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/9467/events","html_url":"https://github.com/pydata/pandas/issues/9467","id":57362106,"number":9467,"title":"BUG/CLN: SparseSeries __getitem__ uses questionable, buggy logic","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},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Sparse","name":"Sparse","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/38","html_url":"https://github.com/pydata/pandas/milestones/0.18.1","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/38/labels","id":1570594,"number":38,"title":"0.18.1","description":"after 0.18.0 of course!","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":190,"closed_issues":131,"state":"open","created_at":"2016-02-08T15:29:59Z","updated_at":"2016-04-10T14:32:47Z","due_on":"2016-04-26T04:00:00Z","closed_at":null},"comments":0,"created_at":"2015-02-11T19:12:29Z","updated_at":"2016-04-10T14:32:46Z","closed_at":"2016-04-10T14:32:46Z","body":"SparseSeries currently relies on the assumption that all non-scalar input will raise a `TypeError` (because it won't be hashable) when used as input to `Index.get_loc`:\r\nhttps://github.com/pydata/pandas/blob/bb9c311f36fbf508d11f2eabe3fdbdd010abf8c0/pandas/sparse/series.py#L361\r\n\r\nHowever, some non-scalar input is hashable (e.g., `Ellipsis`):\r\n```\r\nIn [2]: import pandas as pd\r\n\r\nIn [3]: ss = pd.Series(range(10)).to_sparse()\r\n\r\nIn [4]: ss[...]\r\n---------------------------------------------------------------------------\r\nException                                 Traceback (most recent call last)\r\n<ipython-input-4-f0ccf654123b> in <module>()\r\n----> 1 ss[...]\r\n\r\n/Users/shoyer/dev/pandas/pandas/sparse/series.pyc in __getitem__(self, key)\r\n    369             if isinstance(key, (int, np.integer)):\r\n    370                 return self._get_val_at(key)\r\n--> 371             raise Exception('Requested index not in this series!')\r\n    372\r\n    373         except TypeError:\r\n\r\nException: Requested index not in this series!\r\n```\r\n(this should return the entire sparse series)\r\n\r\nThis logic is also problematic because it relies on `get_loc` always throwing `TypeError` for invalid input. So this could use some cleanup, ideally checking directly if the input is hashable. And it probably shouldn't be raising a generic `Exception`, either.\r\n\r\nxref tslib.pyx change/discussion in #9258"}}