{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/12416","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/12416/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/12416/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/12416/events","html_url":"https://github.com/pydata/pandas/issues/12416","id":135385662,"number":12416,"title":"Wrong behaviour/error when indexing MultiIndex with list","user":{"login":"toobaz","id":1224492,"avatar_url":"https://avatars.githubusercontent.com/u/1224492?v=3","gravatar_id":"","url":"https://api.github.com/users/toobaz","html_url":"https://github.com/toobaz","followers_url":"https://api.github.com/users/toobaz/followers","following_url":"https://api.github.com/users/toobaz/following{/other_user}","gists_url":"https://api.github.com/users/toobaz/gists{/gist_id}","starred_url":"https://api.github.com/users/toobaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toobaz/subscriptions","organizations_url":"https://api.github.com/users/toobaz/orgs","repos_url":"https://api.github.com/users/toobaz/repos","events_url":"https://api.github.com/users/toobaz/events{/privacy}","received_events_url":"https://api.github.com/users/toobaz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Indexing","name":"Indexing","color":"0b02e1"},{"url":"https://api.github.com/repos/pydata/pandas/labels/MultiIndex","name":"MultiIndex","color":"207de5"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-02-22T11:04:17Z","updated_at":"2016-09-14T14:57:19Z","closed_at":null,"body":"    In [2]: df = pd.DataFrame(index=range(2), columns=pd.MultiIndex.from_product([[10,20], ['a', 'b']]))\r\n\r\n    In [3]: df[[20]]\r\n    ---------------------------------------------------------------------------\r\n    IndexError                                Traceback (most recent call last)\r\n    <ipython-input-3-8422ebb3f356> in <module>()\r\n    ----> 1 df[[20]]\r\n\r\n    /home/pietro/nobackup/repo/pandas/pandas/core/frame.pyc in __getitem__(self, key)\r\n       1975         if isinstance(key, (Series, np.ndarray, Index, list)):\r\n       1976             # either boolean or fancy integer index\r\n    -> 1977             return self._getitem_array(key)\r\n       1978         elif isinstance(key, DataFrame):\r\n       1979             return self._getitem_frame(key)\r\n\r\n    /home/pietro/nobackup/repo/pandas/pandas/core/frame.pyc in _getitem_array(self, key)\r\n       2020         else:\r\n       2021             indexer = self.ix._convert_to_indexer(key, axis=1)\r\n    -> 2022             return self.take(indexer, axis=1, convert=True)\r\n       2023 \r\n       2024     def _getitem_multilevel(self, key):\r\n\r\n    /home/pietro/nobackup/repo/pandas/pandas/core/generic.pyc in take(self, indices, axis, convert, is_copy)\r\n       1590         new_data = self._data.take(indices,\r\n       1591                                    axis=self._get_block_manager_axis(axis),\r\n    -> 1592                                    convert=True, verify=True)\r\n       1593         result = self._constructor(new_data).__finalize__(self)\r\n       1594 \r\n\r\n    /home/pietro/nobackup/repo/pandas/pandas/core/internals.pyc in take(self, indexer, axis, verify, convert)\r\n       3617         n = self.shape[axis]\r\n       3618         if convert:\r\n    -> 3619             indexer = maybe_convert_indices(indexer, n)\r\n       3620 \r\n       3621         if verify:\r\n\r\n    /home/pietro/nobackup/repo/pandas/pandas/core/indexing.pyc in maybe_convert_indices(indices, n)\r\n       1803     mask = (indices >= n) | (indices < 0)\r\n       1804     if mask.any():\r\n    -> 1805         raise IndexError(\"indices are out-of-bounds\")\r\n       1806     return indices\r\n       1807 \r\n\r\n    IndexError: indices are out-of-bounds\r\n\r\nand\r\n\r\n    In [4]: df[[1]]\r\n    Out[4]: \r\n        10\r\n         b\r\n    0  NaN\r\n    1  NaN\r\n\r\nshould both raise ``KeyError`` (see https://github.com/pydata/pandas/issues/12369#issuecomment-187065056 )"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/247040985","html_url":"https://github.com/pydata/pandas/issues/12416#issuecomment-247040985","issue_url":"https://api.github.com/repos/pydata/pandas/issues/12416","id":247040985,"user":{"login":"EricPrescottGagnon","id":10046734,"avatar_url":"https://avatars.githubusercontent.com/u/10046734?v=3","gravatar_id":"","url":"https://api.github.com/users/EricPrescottGagnon","html_url":"https://github.com/EricPrescottGagnon","followers_url":"https://api.github.com/users/EricPrescottGagnon/followers","following_url":"https://api.github.com/users/EricPrescottGagnon/following{/other_user}","gists_url":"https://api.github.com/users/EricPrescottGagnon/gists{/gist_id}","starred_url":"https://api.github.com/users/EricPrescottGagnon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricPrescottGagnon/subscriptions","organizations_url":"https://api.github.com/users/EricPrescottGagnon/orgs","repos_url":"https://api.github.com/users/EricPrescottGagnon/repos","events_url":"https://api.github.com/users/EricPrescottGagnon/events{/privacy}","received_events_url":"https://api.github.com/users/EricPrescottGagnon/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T14:57:19Z","updated_at":"2016-09-14T14:57:19Z","body":"I am obtaining similar issues with a DateTimeIndex.\r\n\r\n```\r\nIn[1]: df = pandas.DataFrame(0, index=pandas.date_range('1/8/2011', periods=5, freq='W'), columns=['a', 'b'])\r\nIn[2]: df\r\nOut[2]: \r\n            a  b\r\n2011-01-09  0  0\r\n2011-01-16  0  0\r\n2011-01-23  0  0\r\n2011-01-30  0  0\r\n2011-02-06  0  0\r\n\r\nIn[3]: df.loc[list(pandas.date_range('1/1/2011', periods=4, freq='W'))]\r\nOut[3]: \r\n              a    b\r\n2011-01-02  NaN  NaN\r\n2011-01-09  0.0  0.0\r\n2011-01-16  0.0  0.0\r\n2011-01-23  0.0  0.0\r\n\r\nIn[4]: df.loc[tuple(pandas.date_range('1/1/2011', periods=4, freq='W'))]\r\nTraceback (most recent call last):\r\n  File \"C:\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\", line 1395, in _has_valid_type\r\n    error()\r\n  File \"C:\\Anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py\", line 1390, in error\r\n    (key, self.obj._get_axis_name(axis)))\r\nKeyError: 'the label [2011-01-02 00:00:00] is not in the [index]'\r\n```\r\n"}}
{"actor":{"display_login":"EricPrescottGagnon"}}