[Solved] Pandas--TypeError: ‘bool‘ object is not iterable
[Solved] Pandas–TypeError: ‘bool’ object is not iterable
import pandas as pd
df = pd.read_csv(ori_file_name, names=['img_name','label'])
df.to_csv(new_file_name, index=False, columns= False)
报错:
df.to_csv(new_file_name, index=False, columns= False)
TypeError: 'bool' object is not iterable
Solved
bool 类型的数据不可迭代,就说明采用布尔值的地方出错了,通过查找源代码,发现columns=None 或者列表赋值,因而columns=False 会导致错误,正确代码如下:
import pandas as pd
df = pd.read_csv(ori_file_name, names=['img_name','label'])
df.to_csv(new_file_name, index=False, columns= ['img_name','label'])
#df.to_csv(new_file_name, index=False ) #或者采用默认值
小结:
这种错误的排查有两个思路
1)数据本身问题
2)错误调用
[Solved] Pandas--TypeError: ‘bool‘ object is not iterable相关推荐
- Python+selenium自动化测试:报错:TypeError: 'WebElement' object is not iterable
代码: # -*- coding: utf-8 -*-from selenium import webdriverfrom selenium.webdriver.common.by import By ...
- python nonetype_【已解决】Python程序错误:TypeError: ‘NoneType’ object is not iterable
[问题] 如下代码:def callBlogFunc(funcToCall, *paraList): funcName = funcToCall.func_name; if(blogIsNetease ...
- 成功解决TypeError int object is not iterable
成功解决TypeError: 'int' object is not iterable 目录 解决问题 解决思路 解决方法 解决问题 TypeError: 'int' object is not it ...
- Python报错TypeError: ‘User‘ object is not iterable
Python报错TypeError: 'User' object is not iterable 原因 User对象是不可迭代的,我这里是因为User并不是list,所以是不可迭代的,所以不使用迭代即 ...
- 【Python】处理 TypeError: ‘FirefoxWebElement‘ object is not iterable
编写下面的代码: from selenium import webdriverdriver = webdriver.Firefox() driver.maximize_window() driver. ...
- TypeError: 'float' object is not iterable
求心率的peason相关系数的时候遇到这个问题: TypeError: 'float' object is not iterable 解决方法: pre_label.extend(output) ty ...
- python常见错误 TypeError: 'NoneType' object is not iterable
TypeError: 'NoneType' object is not iterable 1. 将None赋给多个值时,会出现提示:TypeError: 'NoneType' object is no ...
- TF:jupyter notebook中plt.grid设置后不显示网格以及“TypeError: ‘bool‘ object is not callable”错误
1 问题背景 在TF学习过程中,使用jupyter notebook,plt绘制序列并显示网格.但是在运行过程中,发现,代码可以正常运行,但是网格无法显示. 完整代码如下: import matplo ...
- 解决PythonDjango错误“TypeError: ‘bool‘ object is not callable”
[参考链接] python-flask 教程学习过程遇到难题TypeError: 'bool' object is not callablehttps://link.jianshu.com/?t=ht ...
最新文章
- C# 日志框架的添加
- ARM Cortex-M0微控制器汇编语言之分支条件的典型用法
- Meditation Guide
- 【机器学习】算法面试知识点整理(持续更新中~)
- 显示计算机程序的表格如何打开,电脑表格怎么小窗口显示不出来怎么办
- 学校计算机教学演示,案例演示在计算机基础教学中的运用
- android四个按钮平分,android 水平平分两个按钮
- [Ext JS 4] 实战之Grid, Tree Gird编辑Cell
- 8数据提供什么掩膜产品_英特尔推出多款数据中心产品:继续提供差异化选项...
- 1、http网络编程——URL、CURL、CURLcode和curl_slist
- 大唐杯5G题库大全(1)
- 2022 RoboCom 世界机器人开发者大赛-本科组(省赛)RC-u4 攻略分队
- Barsetto百胜图TripressoES意式便携咖啡机测评,咖啡随行玩味无穷
- [linux] 命令
- Intel 12代处理器主机 安装Ubuntu
- nginx官网下载百度云分享
- 基于飞凌FETA40i-C核心板在光时域反射仪中的应用原理
- 初识pyQt5之简易翻译软件
- 2019考研政治【韦林】全程班视频
- sja1000 中断_关于单片机+SJA1000接收中断C语言编程的问题
热门文章
- 微信小程序 界面从右边滑出_微信小程序页面溢出左右滑动问题
- MFC中改变按钮颜色的方法
- pinyin4j:拼音与汉字的转换实例
- 互联网的行业都有哪些岗位?
- 贝佐斯“上天”后,亚马逊云还能飘多高?
- 聊天室登录php,聊天室技术(二)-- 登录_PHP
- 整合spring cloud云架构 - SSO单点登录之OAuth2.0登录流程
- iOS使用UICollectionView只允许向左方向滑动,不允许向右方向滑动。
- Java中Properties类的使用
- 中国一汽发布L4级智能驾驶技术,解放商用车率先使用;科大讯飞今日将发翻译机2.0版本;阿里巴巴已以50亿控股全球第二大WiFi芯片商乐鑫信息科技