Search and copy values from one column, copy it to new one and then remove it from first column

  pandas, python

I have a DataFrame column named locations containing mixed values of cities and countries such as following

 locations
 USA, New York City, Philadelphia
 Mumbai, Delhi 
 England, London
 India, Japan, Tokyo
 United States of America, Los Angelus,
 Toronto, Vancouver 

I need to copy country names from this column to another column, also there are columns containing multiple country names, I need to copy just first country name. There are values such as England and UK as well. Once copied I need to remove these values from locations column.

Pandas has a method .copy() which can be used to copy values from on columns to another, but I have to search all the countries and then remove from locations. Can some help me how can I do this?

Source: Python Questions

LEAVE A COMMENT