python - Pandas: Replace full match string from dictionary -


this question has answer here:

i'm using dictionary replace of entries in data frame:

dict1 = {     "republic of korea": "south korea",     "united states of america": "united states",     "united kingdom of great britain , northern ireland": "united kingdom",     "china, hong kong special administrative region": "hong kong" } 

using df.replace() accomplishes work:

energy['country'] = energy['country'].replace(dict1, regex=true)

however, realized function replacing every string match , want limit replace function full string matches i'm getting unwanted replacings like:

"democratic people's republic of korea" miss-cleaned "democratic people's south korea"

i tried use regex in dictionary seems not work.

any idea? in advance.

remove regex=true specify full replacement.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -