{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/11201","labels_url":"https://api.github.com/repos/pydata/pandas/issues/11201/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/11201/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/11201/events","html_url":"https://github.com/pydata/pandas/issues/11201","id":108789988,"number":11201,"title":"BUG: unexpected KeyError with Index.get_loc","user":{"login":"liuyu81","id":885656,"avatar_url":"https://avatars.githubusercontent.com/u/885656?v=3","gravatar_id":"","url":"https://api.github.com/users/liuyu81","html_url":"https://github.com/liuyu81","followers_url":"https://api.github.com/users/liuyu81/followers","following_url":"https://api.github.com/users/liuyu81/following{/other_user}","gists_url":"https://api.github.com/users/liuyu81/gists{/gist_id}","starred_url":"https://api.github.com/users/liuyu81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liuyu81/subscriptions","organizations_url":"https://api.github.com/users/liuyu81/orgs","repos_url":"https://api.github.com/users/liuyu81/repos","events_url":"https://api.github.com/users/liuyu81/events{/privacy}","received_events_url":"https://api.github.com/users/liuyu81/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/Difficulty%20Intermediate","name":"Difficulty Intermediate","color":"fbca04"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Effort%20Low","name":"Effort Low","color":"006b75"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Indexing","name":"Indexing","color":"0b02e1"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Prio-low","name":"Prio-low","color":"FFFFC0"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/20","html_url":"https://github.com/pydata/pandas/milestones/Someday","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/20/labels","id":239227,"number":20,"title":"Someday","description":"Milestone for filing things away that may be reached someday (at which point such issues should be moved to the appropriate release milestone)","creator":{"login":"wesm","id":329591,"avatar_url":"https://avatars.githubusercontent.com/u/329591?v=3","gravatar_id":"","url":"https://api.github.com/users/wesm","html_url":"https://github.com/wesm","followers_url":"https://api.github.com/users/wesm/followers","following_url":"https://api.github.com/users/wesm/following{/other_user}","gists_url":"https://api.github.com/users/wesm/gists{/gist_id}","starred_url":"https://api.github.com/users/wesm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wesm/subscriptions","organizations_url":"https://api.github.com/users/wesm/orgs","repos_url":"https://api.github.com/users/wesm/repos","events_url":"https://api.github.com/users/wesm/events{/privacy}","received_events_url":"https://api.github.com/users/wesm/received_events","type":"User","site_admin":false},"open_issues":245,"closed_issues":141,"state":"open","created_at":"2013-01-06T03:02:01Z","updated_at":"2015-09-29T10:08:48Z","due_on":"2016-12-31T05:00:00Z","closed_at":null},"comments":9,"created_at":"2015-09-29T03:56:45Z","updated_at":"2015-09-29T11:32:07Z","closed_at":null,"body":"`Index.get_loc` raises unexpected `KeyError` when `data` is a 2-dimensional `numpy.ndarray` with non-unique, monotonically increasing values, i.e.,\r\n\r\n    >>> import numpy as np\r\n    >>> import pandas as pd\r\n    >>> ix = pd.Index(np.array([[\"A\"], [\"A\"], [\"B\"]]))\r\n    >>> ix.get_loc(ix[0])\r\n    Traceback (most recent call last):\r\n      File \"<stdin>\", line 1, in <module>\r\n      File \"/usr/lib/python2.7/site-packages/pandas/core/index.py\", line 1572, in get_loc\r\n        return self._engine.get_loc(_values_from_object(key))\r\n      File \"pandas/index.pyx\", line 134, in pandas.index.IndexEngine.get_loc (pandas/index.c:3824)\r\n      File \"pandas/index.pyx\", line 149, in pandas.index.IndexEngine.get_loc (pandas/index.c:3651)\r\n      File \"pandas/index.pyx\", line 169, in pandas.index.IndexEngine._get_loc_duplicates (pandas/index.c:3990)\r\n    KeyError: ('A',)\r\n\r\nBut it works correctly when the `Index` is either unique, i.e.,\r\n\r\n    >>> ix = pd.Index(np.array([[\"A\"], [\"B\"], [\"C\"]]))\r\n    >>> ix.get_loc(ix[0])\r\n    0\r\n\r\nor non-monotonic, i.e.,\r\n\r\n    >>> ix = pd.Index(np.array([[\"A\"], [\"B\"], [\"A\"]]))\r\n    >>> ix.get_loc(ix[0])\r\n    array([ True, False,  True], dtype=bool)\r\n\r\np.s. `pandas.__version__` 0.16.2; `numpy.__version__` 1.9.3\r\n"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/144032211","html_url":"https://github.com/pydata/pandas/issues/11201#issuecomment-144032211","issue_url":"https://api.github.com/repos/pydata/pandas/issues/11201","id":144032211,"user":{"login":"liuyu81","id":885656,"avatar_url":"https://avatars.githubusercontent.com/u/885656?v=3","gravatar_id":"","url":"https://api.github.com/users/liuyu81","html_url":"https://github.com/liuyu81","followers_url":"https://api.github.com/users/liuyu81/followers","following_url":"https://api.github.com/users/liuyu81/following{/other_user}","gists_url":"https://api.github.com/users/liuyu81/gists{/gist_id}","starred_url":"https://api.github.com/users/liuyu81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liuyu81/subscriptions","organizations_url":"https://api.github.com/users/liuyu81/orgs","repos_url":"https://api.github.com/users/liuyu81/repos","events_url":"https://api.github.com/users/liuyu81/events{/privacy}","received_events_url":"https://api.github.com/users/liuyu81/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T11:32:07Z","updated_at":"2015-09-29T11:32:07Z","body":"@jorisvandenbossche Thank you so much for the suggestion, using `MultiIndex` did solve the problem elegantly. We appreciate the time of all responders and the amazing community support of the `pandas` team at large."}}