DataFrame/Series运行round()函数报错“TypeError: a float is required”解决办法
来源:互联网 发布:sql server打开mysql 编辑:程序博客网 时间:2024/06/07 05:21
DataFrame/Series运行round()函数报错“TypeError: a float is required”解决办法
原代码片段:
#把数据按年龄分层,然后按照不同层进行分组统计人数。aggResult = data.groupby( by=['年龄分层'])['年龄'].agg({ '人数': numpy.size}) a = aggResult/aggResult.sum()pAggResult = round(a,2)*100
返回结果报错:
#TypeError:a float is required
原因:计算结果a返回的是series. 而round()在()内调用参数需要a为float。
解决办法:修改原代码round(a,2) 为a.round(2)
aggResult = data.groupby( by=['年龄分层'])['年龄'].agg({ '人数': numpy.size}) a = aggResult/aggResult.sum()pAggResult = a.round(2)*100
阅读全文
0 0
- DataFrame/Series运行round()函数报错“TypeError: a float is required”解决办法
- python socket send 函数 报错:TypeError: a bytes-like object is required, not 'str'
- python mysql插入数据报错:TypeError: %d format: a number is required, not str
- scrapy domz报错TypeError: 'float' object is not iterable
- python3.5 模拟UDP客户端发送数据报文,报错:TypeError: a bytes-like object is required, not 'str'
- js 函数报错“Uncaught: TypeError xxx is not a function”
- js报错:TypeError: document.GetElementById is not a function
- js报错 :TypeError: yanzhengma is not a function
- js报错:TypeError: document.GetElementById is not a function
- [Sencha ExtJS] 关于build production后,浏览器运行报错'Uncaught TypeError: c is not a function/constructor'
- TypeError: a bytes-like object is required, not 'str'
- python3 TypeError: a bytes-like object is required, not 'str'
- python3 TypeError: a bytes-like object is required, not 'str'
- TypeError: a bytes-like object is required, not 'str'
- TypeError: a bytes-like object is required, not 'str'
- python框架Scrapy报错TypeError: 'float' object is not iterable解决
- Scrapy使用shell命令报错scrape shell TypeError: 'float' object is not iterable
- 登录报错:A granted authority textual representation is required
- java包以及finanlly关键字
- 视频检测之:利用显著运动检测的 block-sparse RPCA
- mabatis <if>
- HDU 1272 小希的迷宫 (并查集)
- CCS7.2的下载、安装及打开CCS3.3工程文件
- DataFrame/Series运行round()函数报错“TypeError: a float is required”解决办法
- Linux ssh登录命令
- Oracle学习笔记(六)管理表
- 重启服务器后Tomcat在Windows端口异常占用的处理(socked bind failed)
- js:异步时函数返回值问题
- 手工搭建React+Webpack初级开发环境
- Netty学习之---TCP粘包和拆包
- canvas粒子雪花效果
- 【机房合作】Visualsvn的安装