Feb-24-2017, 10:37 AM
You have no "wildcards" there
Output:In [39]: import pandas as pd
In [40]: df = pd.DataFrame({"country":["United Kingdom of Great Britain", "Ireland", "United Kingdom of Great Britain & Ireland"], "value":[12,31, 43]})
In [41]: df
Out[41]:
country value
0 United Kingdom of Great Britain 12
1 Ireland 31
2 United Kingdom of Great Britain & Ireland 43
In [42]: df.country.replace("^United Kingdom of Great Britain.*", "United Kingdom", regex=True, inplace=True)
In [43]: df
Out[43]:
country value
0 United Kingdom 12
1 Ireland 31
2 United Kingdom 43