0

I'm runing a python function to download some arquives, to do that I've to manually set some paramters (X,Y,Z). But I've to download several itens and I'm not in the mood to do that manually. How I set up my script to select a row in a DF execute my download function and when its complet move to the next one.

Ex:

df = df.csv
for n, row in df.iterrows():
    X,Y,Z = row['X'], row['Y'],row['Z']
#where "n" is my first position, kinda index = 1
for n in n 
   download():
   break

No clue how to do that.

  • Does this answer your question? [How to iterate over rows in a DataFrame in Pandas](https://stackoverflow.com/questions/16476924/how-to-iterate-over-rows-in-a-dataframe-in-pandas) – Taren Sanders Jul 12 '23 at 00:45
  • HI Emanuel! Welcome to StackOverflow. I would recommend making your example reproducible. See https://stackoverflow.com/help/minimal-reproducible-example – Mark Jul 12 '23 at 01:57

1 Answers1

0

Maybe you can use something like:

def download(x, y, z):
    # download archive
    ...
    return result

for n, row in df.iterrows():
    X, Y, Z = row[['X', 'Y', 'Z']]
    result = download(X, Y, Z)
    # process result
    ...
Corralien
  • 109,409
  • 8
  • 28
  • 52