pandas dataframe遍历时数据类型为float无法遍历

报错:TypeError: 'float' object is not subscriptable

 

 

 

https://www.delftstack.com/zh/howto/python-pandas/how-to-convert-float-to-int-in-pandas-dataframe/

 

转化为int之后,再用列表填充,遍历列表

k2 = pd.to_numeric(stock_a_all_pb_df.values[-1, 1:], downcast='integer')
i2 = []
for p2 in k2:
i2.append(p2)
posted @ 2022-04-04 12:16  星涅爱别离  阅读(160)  评论(0编辑  收藏  举报