Python教程

python中pandas for遍历所有行以及其中列的值

本文主要是介绍python中pandas for遍历所有行以及其中列的值,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#假设示例
teas = pd.DataFrame(columns=['name','url'])
teas.loc[0] = ['陈xx','http://xxx.htm']
teas.loc[1] = ['黄xx','http://xxx.htm']
teas.loc[2] = ['朱xx','http://xxx.htm']

#遍历行的下标以及其中列的值
for ind, row in teas.iterrows():
    print(ind)
    print(row['name'])
    print(row['url'])
这篇关于python中pandas for遍历所有行以及其中列的值的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!