Feb-24-2017, 09:36 AM
Dear Pandas Experts,
I am trying to replace occurences like "United Kingdom of Great Britain and Ireland" or "United Kingdom of Great Britain & Ireland"
with just "United Kingdom". So I thought I use a regex to look for strings that contain "United Kingdom".
However, my two attempts below do not work:
I am trying to replace occurences like "United Kingdom of Great Britain and Ireland" or "United Kingdom of Great Britain & Ireland"
with just "United Kingdom". So I thought I use a regex to look for strings that contain "United Kingdom".
However, my two attempts below do not work:
dftwo['Country'].replace(r'^United Kingdom of Great Britain','United Kingdom',inplace=True, regex=True) dftwo['Country'].replace('/United Kingdom/','United Kingdom',inplace=True, regex=True)I would really appreciate any help!