Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Iteration Help
#1
Hi;

i create a code for find a replace words of a list. But i had a proble in the iterarion of this code, only change the first word

def dictionary_unique(df, file, column = 'Word'):
    
    dictionary = pd.read_csv(file, dtype=str, encoding='latin1', sep=';')
    df = df[column].values.tolist()
    read_words = dictionary['Word_Comp'].values.tolist()
    replace_word = dictionary['Replace'].values.tolist()
    
    elem = {k: i for i, k in enumerate(df)} 
    Output = list(map(elem.get, read_words))
    
    
        
    for index, replacement in zip(Output, replace_word):
        df[index] = replacement
        
        return df
please HELP
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020