{"action":"opened","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/11640","labels_url":"https://api.github.com/repos/pydata/pandas/issues/11640/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/11640/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/11640/events","html_url":"https://github.com/pydata/pandas/issues/11640","id":117597807,"number":11640,"title":"BUG AttributeError: 'DataFrameGroupBy' object has no attribute '_obj_with_exclusions'","user":{"login":"nbonnotte","id":9929982,"avatar_url":"https://avatars.githubusercontent.com/u/9929982?v=3","gravatar_id":"","url":"https://api.github.com/users/nbonnotte","html_url":"https://github.com/nbonnotte","followers_url":"https://api.github.com/users/nbonnotte/followers","following_url":"https://api.github.com/users/nbonnotte/following{/other_user}","gists_url":"https://api.github.com/users/nbonnotte/gists{/gist_id}","starred_url":"https://api.github.com/users/nbonnotte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbonnotte/subscriptions","organizations_url":"https://api.github.com/users/nbonnotte/orgs","repos_url":"https://api.github.com/users/nbonnotte/repos","events_url":"https://api.github.com/users/nbonnotte/events{/privacy}","received_events_url":"https://api.github.com/users/nbonnotte/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-18T14:27:07Z","updated_at":"2015-11-18T14:27:07Z","closed_at":null,"body":"I guess it will be clearer with an example. First, let's prepare the dataframe:\r\n```\r\nIn [2]: df = pd.DataFrame(columns=['a','b','c','d'], data=[[1,'b1','c1',3], [1,'b2','c2',4]])\r\n\r\nIn [3]: df = df.pivot_table(index='a', columns=['b','c'], values='d').reset_index()\r\n\r\nIn [4]: df\r\nOut[28]: \r\nb  a b1 b2\r\nc    c1 c2\r\n0  1  3  4\r\n```\r\n\r\nNow, the exception raised:\r\n```\r\nIn [5]: df.groupby('a').mean()\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\n<ipython-input-29-a830c6135818> in <module>()\r\n----> 1 df.groupby('a').mean()\r\n\r\n/home/nicolas/Git/pandas/pandas/core/groupby.py in mean(self)\r\n    764             self._set_selection_from_grouper()\r\n    765             f = lambda x: x.mean(axis=self.axis)\r\n--> 766             return self._python_agg_general(f)\r\n    767 \r\n    768     def median(self):\r\n\r\n/home/nicolas/Git/pandas/pandas/core/groupby.py in _python_agg_general(self, func, *args, **kwargs)\r\n   1245                 output[name] = self._try_cast(values[mask], result)\r\n   1246 \r\n-> 1247         return self._wrap_aggregated_output(output)\r\n   1248 \r\n   1249     def _wrap_applied_output(self, *args, **kwargs):\r\n\r\n/home/nicolas/Git/pandas/pandas/core/groupby.py in _wrap_aggregated_output(self, output, names)\r\n   3529     def _wrap_aggregated_output(self, output, names=None):\r\n   3530         agg_axis = 0 if self.axis == 1 else 1\r\n-> 3531         agg_labels = self._obj_with_exclusions._get_axis(agg_axis)\r\n   3532 \r\n   3533         output_keys = self._decide_output_index(output, agg_labels)\r\n\r\n/home/nicolas/Git/pandas/pandas/core/groupby.py in __getattr__(self, attr)\r\n    557 \r\n    558         raise AttributeError(\"%r object has no attribute %r\" %\r\n--> 559                              (type(self).__name__, attr))\r\n    560 \r\n    561     def __getitem__(self, key):\r\n\r\nAttributeError: 'DataFrameGroupBy' object has no attribute '_obj_with_exclusions'\r\n``` \r\n\r\nMaybe I'm doing something wrong, and it's not a bug, but then the exception raised should definitely be more explicit than a reference to an internal attribute :-)\r\n\r\nThis attribute, by the way, is (only) referenced in one file and in issue #5264. It might be connected, but the discussion is a bit long and technical. \r\n\r\nI'll try to have a look at what's going on."}}