stock是一组dataframe数据,我想用for循环遍历stock中两列的数据
我的代码是:
for x,y in stock[['A','B']]:
print(x,y)
运行结果为:
too many values to unpack (expected 2)
请问哪里出了问题?
stock是一组dataframe数据,我想用for循环遍历stock中两列的数据
我的代码是:
for x,y in stock[['A','B']]:
print(x,y)
运行结果为:
too many values to unpack (expected 2)
请问哪里出了问题?
stock['A','B']是一个数据框类型,直接解包会出错,你可以这样操作:
for x ,y in zip(stock['A'],stock['B']):
print(x,y)