I have a data frame with country and traffic columns:
Country | Traffic
US 8687
Italy 902834
Germany 2343
Brazil 4254
France 23453
I want to add a third column called "Region" to this data frame. It would look like this:
Country | Traffic | Region
US 8687 US
Italy 902834 EU
Germany 2343 EU
Brazil 4254 LA
France 23453 EU
The following code works if I have only two Regions. I am looking more for an if/else
, map
, or lambda
statement:
df['Region'] = np.where(df['Country'] == 'US', 'US', 'EU')
Thank You.