pandas-11 TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely错误解决方法
2024-09-05 08:56:42
pandas-11 TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely错误解决方法
将一个list矩阵转化为numpy数组之后,使用np.isnan()方法,报出了这么一个错误:
TypeError: ufunc ‘isnan’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ‘‘safe’’
经过测试,发现是二维list转化为numpy数组的时候就存在问题了。
出错原因是list第二维的元素个数不一致导致如:
list1 = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9, 10]]
这时候使用 np.array(list1),输出如下内容:
[
list(1, 2, 3),
list(4, 5, 6),
list(7, 8, 9, 10)]
接着使用np.isnan()方法,就会报出最上面的错误。
因为第三行是4个元素,所以无法转化为我们想要的numpy数组,解决方法就是将列数改为一致即可。
最新文章
- [LeetCode] Best Time to Buy and Sell Stock II
- 国内外前端(js)开发框架对比
- OpenCascade Tcl vs. ACIS Scheme
- Mysql --分区表(1)
- React-router 要点
- Kooboo中怎么新增一个关联的Details 动态页面。
- 换成gnome3桌面后国际版qq不能输入中文问题
- 【CEOI2004】锯木厂选址
- Android--------Java接口回调
- 关于” fatal error C1010: unexpected end of file while looking forprecompiled header directive”问题
- Oracle100w数据大表割接
- markdown笔记实现页内目录跳转
- mysql批量更新数据
- 前端AES解密
- javascript中的 return false和return true
- Educational Codeforces Round 2	E - Lomsat gelral
- f5 Seldom used
- dede的织梦问答模块也可以支持arclist标签
- springmvc使用list集合实现商品列表的批量修改
- lsmod命令详解
热门文章
- PHP系列 | PHPexcel导入xls格式 ,提示错误:iconv(): Wrong charset, conversion from `CP936' to `UTF-8' is not allowed
- Comparable接口的使用
- 2019年MTP管理技能提升培训笔记
- 求解未知数——yjy题库
- nginx 安装 ssl 证书
- 小于K的两数之和
- Web API之Web Components
- linux 资源
- haproxy转发真实IP给web
- 打包工具Gradle