ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
错误原因是Nexcel是dateframe类型,但我使用os.path.realpath(Nexcel) 获取其路径报错。
Nexcel = pd.DataFrame() # 只是一个圆括号的话说明创建的数据表是空的
ExcelName = filepath + '/{}.xlsx'.format(tempfilename + '拆分' + self.leix + self.sheet_name)#Excel保存位置
Nexcel.to_excel(ExcelName) # 调用to_excel 方法
os.path.realpath(Nexcel)
本文解决了一个关于pandas DataFrame类型的对象在尝试使用os.path.realpath获取文件路径时出现的ValueError错误。错误提示表明了直接对DataFrame求真值是不明确的,并提供了正确的处理方式。
6813

被折叠的 条评论
为什么被折叠?



