Iteration of DF’s in pandas

Asked

Viewed 27 times

0

This is guys speaking. Assuming I have a df1 with only one ID column, and another df2 with information I want to register in that df1. But I need q each id of df1 repeat for all df2 information

For example.

df1= [1, 2, 3, 4]

df2= [info1, info2, info3]

df_final = [ 1 -> info1, 1-> info2, 1->info3 ... 4->info3]

I’m trying to make one go, into another go. I created a helper id for df2 for this to be done, but I can’t get the expected result, although the log I believe q is correct.

for id1, row in df1.iterrows():
   for id2, row in df2.iterrows():
      df1[colunadeinformações] = df2[colunadeinformações]
   

Is there any function that you can recommend me to study so that I get something similar to the exposed ? thank you in advance.

  • See this: https://stackoverflow.com/a/464050/1452488

  • Wow, perfect! Thank you. How many are in vain I tried. rs.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.