Apr-09-2020, 09:34 PM
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
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 dfplease HELP