I have 2 pandas columns, one has filepath and another column has new folder name, i am trying to replace the folder name with new folder name using regex replace
df['new_path'] = df.root.str.replace(r'A-[0-9]*-END', df.new_folder_name)
I am getting an error repl must be a string or callable , is it possible to replace matched regex with value from corresponding column?
str.replaceallow it. You may extract values by the regex pattern and combine them withdf.new_folder_nameto construct adictto use withreplace