I would like to replace specific strings within a Pandas Series:
For example, energy['Country'] gives me:
233 United States of America
234 United States Virgin Islands
235 Uruguay
236 Uzbekistan
237 Vanuatu
238 Venezuela
239 Viet Nam
240 Wallis and Futuna Islands
241 Yemen
242 Zambia
243 Zimbabwe
However, I would like to replace 'United States of America' with 'United States'.
I have tried using:
energy = energy['Country'].str.replace("United States of America", "United States")
However, this has not worked.
Would anybody be able to give me a helping hand?
energy = energy['Country'].str.strip().str.replace("United States of America", "United States")