This question already has answers here:
How to iterate over rows in a DataFrame in Pandas?
(20个答案)
在11个月前关闭。
我在数据框中包含链接行。
我需要一次遍历数据帧中链接的行,以便可以分别对每个链接执行硒任务。它应该循环遍历这些行,直到数据帧中没有更多行为止。
我的逻辑如下
(20个答案)
在11个月前关闭。
我在数据框中包含链接行。
df = pd.DataFrame()
我需要一次遍历数据帧中链接的行,以便可以分别对每个链接执行硒任务。它应该循环遍历这些行,直到数据帧中没有更多行为止。
links
0 http://linkone
0 http://linktwo
0 http://linkthree
我的逻辑如下
Loop
Get http://linkone in first row of dataframe
Use selenium to perform tasks, such as driver.get(http://linkone)
Gather data from HTML from http://linkone
Continue loop and get row 2, row 3, etc.
最佳答案
在这种情况下,您不需要iterrows()
,只需使用for
循环即可。
只需使用for循环:
关于python - 遍历循环中的数据帧行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55192162/