0

I have two data frames. I want to match the elements of wiki_adj with the index value of poss, using a for loop. I am confused on how to loop through both to find matches. Once the match is found, I need to replace items within a column with boss with the corresponding string from wiki_adj.

print(poss.head())

#secondary dataframe with "ind_num" that corresponds to index value of original dataframe 

wiki_adj = {
'ind_num':['11','20','25','27','35','41','42','48','49','51','54','56','60','61','62'],
'designation':['Illegal (Decriminalized)','Illegal (unenforced)','Illegal 
               (unenforced)','Illegal (unenforced)','Illegal 
               (unenforced)','Legal','Legal','Illegal','Illegal','Illegal 
               (Decriminalized)','Illegal (Decriminalized)','Illegal 
               (unenforced)','Illegal','Illegal (Decriminalized)','Illegal 
               (unenforced)']}

df = pd.DataFrame(wiki_adj) 
dane w
  • 1
  • 3
  • FYI: generally one tries to avoid for loops in dataframes. – D.L Aug 29 '22 at 17:11
  • 1
    the given dict `wiki_adj` has errors, please provide a working minimum reproducable example: https://stackoverflow.com/help/minimal-reproducible-example – D.L Aug 29 '22 at 17:14

0 Answers0