本文主要是介绍TypeError: argument of type ‘float‘ is not iterable报错的解决方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
上周在进行数据分析联系时,遇到这样一个问题,先来看下看些报错原因。
报错原因是“TypeError: argument of type 'float' is not iterable”意思是float型不能进行迭代。报错原因是数据中含有float型数据,需要使用astype方法进行数据类型准换成str运行即可。
报错的代码:
auth_capital['ex_rate'] = auth_capital[1].apply(get_ex_rate)
auth_capital.sample(5)
修改的代码:
auth_capital['ex_rate'] = auth_capital[1].astype(str).apply(get_ex_rate)
auth_capital.sample(5)
修改后的运行结果:
这篇关于TypeError: argument of type ‘float‘ is not iterable报错的解决方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!