'DataFrameGroupBy' object has no attribute 'groupby'
时间: 2023-09-21 10:10:02 浏览: 420
这个错误提示是因为在代码中重复使用了`groupby`方法。根据引用的代码,首先使用`group_by`函数将数据按照`lat`进行分组,然后使用`groupby`方法再次对数据进行分组。然而,在引用中,又对`data_user_buy1`这个`DataFrameGroupBy`对象使用了`groupby`方法,导致出现错误。
解决这个问题的方法是修改引用中的代码,将其中的`groupby`方法的部分改为对`data_user_buy1`进行操作即可。具体修改如下所示:
```
data_user_buy2 = data_user_buy1.sum()['total'] / data_user_buy1.count()['total']
```
这样就不会再出现`'DataFrameGroupBy' object has no attribute 'groupby'`的错误了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [AttributeError: ‘DataFrame‘ object has no attribute ‘dtype](https://blog.csdn.net/q838459755/article/details/117415499)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [成功解决Python3报错:‘DataFrameGroupBy‘ object has no attribute ‘groupby](https://blog.csdn.net/qq_35635728/article/details/116274196)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文