How to replace string values in a column based on a lookup table
问题 I have this df. I'd like to replace every instance of "1.1", "2.1" "3.2", etc. based on a lookup table. Lookup table Desired output I looked at Replace values in a dataframe based on lookup table it doesn't solve my problem. Thanks in advance! 回答1: An option would be gsubfn . We match one or more digits with a dot ( [0-9.]+ ) as the pattern and in the replacement, pass a list of key/value pairs created from the second dataset ('df2'). For the matching pattern with the 'keys', it replace the